Message24137
Logged In: YES
user_id=80475
Sorry, this isn't a bug. The eval() function is documented
to only search globals() and local(). The nested scope of
eval's caller is not included.
In your code, callfunction2 works because callfunction1 can
be found in the nested scope.
In contrast, evalfunction2 fails because evalfunction1 is
not in the locals() or globals(); instead, is in a enclosing
nested scope which is not searched.
The reason that evalfunction2 works if you uncomment the
extra code is the subsequent reference to evalfunction1 gets
it brought into locals() at compilation time (when the def
is executed).
For real code, is you want a nested scope object to be found
by eval, then either reference it in the same function that
calls eval() or, more explicitly, just add it to a
dictionary of things that should be visible to eval(). |
|
| Date |
User |
Action |
Args |
| 2007-08-23 14:29:18 | admin | link | issue1115039 messages |
| 2007-08-23 14:29:18 | admin | create | |
|