exec and globals and locals ...
Eko palypse <ekopalypse at gmail.com> writes:
> Why does f1 work? I've expected an exception as no global dict has been provided
The documentation ("https://docs.python.org/3/library/functions.html#exec")
exec(object[, globals[, locals]])
In all cases, if the optional parts are omitted, the code is executed in the current scope. ...
You can see from it that "globals" is optional.
And that, if "globals" is missing, then
"exec" is executed in the current scope ("f1" in your case).