Returning a value from exec or a better solution
Ethan Furman
ethan at stoneleaf.us
Tue Aug 30 18:31:42 EDT 2011
Rob Williscroft wrote:
> Arnaud Delobelle wrote:
>
>> That's not an issue. The last statement that is executed will be the
>> "def" statement.
>
> You don't know that, an implementation may for example set __bultins__
> to None, prior to returning, its not an unreasonable thing to do and
> the docs don't say they can't.
Actually, I think it is unreasonable -- by modifying the globals or
locals objects *after* the code has been exec'd, information is being
removed about the environment the code ran in, making introspection (if
nothing else) more difficult.
Good reasons are required to make life difficult (at least with Python).
~Ethan~
More information about the Python-list
mailing list