Author congma
Recipients bruno.loff, congma, docs@python, terry.reedy
Date 2021-03-27.08:26:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616833586.92.0.513445243868.issue43605@roundup.psfhosted.org>
In-reply-to
Content
> I think it is *very* reasonable to expect that calling eval() on a string should have the exact same effect as if the code that is inside the eval had been written as part of the source code.

I don't think Python's execution model is defined this way. The documentation on execution model says:

> The eval() and exec() functions do not have access to the full environment for resolving names. Names may be resolved in the local and global namespaces of the caller. Free variables are not resolved in the nearest enclosing namespace, but in the global namespace.
> footnote: This limitation occurs because the code that is executed by these operations is not available at the time the module is compiled.

https://docs.python.org/3/reference/executionmodel.html#interaction-with-dynamic-features
History
Date User Action Args
2021-03-27 08:26:26congmasetrecipients: + congma, terry.reedy, docs@python, bruno.loff
2021-03-27 08:26:26congmasetmessageid: <1616833586.92.0.513445243868.issue43605@roundup.psfhosted.org>
2021-03-27 08:26:26congmalinkissue43605 messages
2021-03-27 08:26:26congmacreate