This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yorick
Recipients
Date 2005-03-03.11:16:41
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=432579

>No, this issue is not specific to either eval or lambda:

Right, so let me rephrase: The bug occurs when explicitly
evaluating a lambda expression or function definition
statement using eval or exec. (This is an artifact of
Python's strong separation of statements and expressions.)

If this is done "by design", why cannot I find anything
anywhere describing this? If this is just a documentation
oversight, please say so, but then I would also like to have
an explanation of the behaviour.

The fact remains that

    def f(x): eval('x')

works as expected and

    def f(g): eval('lambda x: g(x)')

does not. Why? Both are evaluated at the same time and use
the same environment to look up their variables. The fact
that the 'g' variable in the second case is not evaluated
immediately does not affect its scoping, because that is how
lambda expressions work.

>If you want Python to work 
>differently, write a PEP or a patch, or raise the question in
>the newsgroup/mailing list.

www.python.org told me that this is the place to report bugs
in Python. If that is wrong, we should change the web site.
History
Date User Action Args
2007-08-23 14:29:50adminlinkissue1153622 messages
2007-08-23 14:29:50admincreate