__builtins__

Johann Hibschman johann at physics.berkeley.edu
Tue May 30 20:57:28 EDT 2000


Huaiyu Zhu writes:

> It looks like that I have to use
> 	__builtins__.min (1,2)

> in the interpreter but
> 	__builtins__['min']([1, 2])

> in a module.  Why is this so?

Ah.  You should not be using __builtins__.  As far as I understand it,
that is a hack variable, which you cannot trust.

The module you seek is __builtin__  (no s.)

If you want these functions, the Right Thing is to "import
__builtin__" and then use "__builtin__.min".  The fact that there is a
variable named "__builtins__" is an accident of the implementation.

--Johann

-- 
Johann Hibschman                           johann at physics.berkeley.edu



More information about the Python-list mailing list