Eko palypse <ekopaly...@gmail.com> writes:
> Why does f1 work? I've expected an exception as no global dict has been 
> provided
> ...
>def f1(...):
>  exec("...")
>...

The documentation ("https://docs.python.org/3/library/functions.html#exec";)
tells you:

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).

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to