The namespace for builtin functions?

Francis Avila francisgavila at
Sun Nov 30 06:35:05 CET 2003

Jay O'Connor wrote in message ...
>Blair Hall wrote:
>> Can anyone please tell me how to correctly use a built in function
>> when there is a function of the same name in local scope?
>Save yourself a lot of trouble, just give it a different name.

This is the best advice.


I don't understand why in __main__, the name __builtins__ refers to the
module object __builtin__, but in any other namespace, __builtins__ is the
__dict__ of __builtin__!

--- ---
a = lambda: __builtins__
--- END ---

>>> __builtins__
<module '__builtin__' (built-in)>
>>> id(__builtins__)
>>> id(__builtins__.__dict__)
>>> import a
>>> id(a.a())

Why not 6577648?!
Francis Avila

More information about the Python-list mailing list