Oddity in 2.4 with eval('None')

Steve Holden steve at holdenweb.com
Mon Dec 20 22:18:05 CET 2004

Leif K-Brooks wrote:

> Steve Holden wrote:
>> Yes. "print eval('None')" is printing the value of None as defined in 
>> your module's global namespace:
> Right, but why? The expression "None" doesn't worry about the global 
> namespace when used in normal code; why does it when used in eval()ed code?

I have no idea why. Given that

  >>> eval("globals()['__builtins__'].globals().keys()")
['None', '__builtins__', '__file__', 'sys', '__name__', '__doc__']

it's beginning to smell a bit like a buglet.

Steve Holden               http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC      +1 703 861 4237  +1 800 494 3119

More information about the Python-list mailing list