The namespace for builtin functions?

Fredrik Lundh fredrik at pythonware.com
Sun Nov 30 19:00:16 CET 2003


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?
>
> Here is an example. Suppose the following is in myApply.py:
>
> def apply(func,seq):
>      #
>      # Code can default to
>      # built-in definition in some cases:
>      return __builtins__.apply(func,seq)

the module is named __builtin__, and must be imported before
it can be used.

__builtins__ is a CPython implementation detail (it's used to cache
a reference to the builtin modules, and are initialized on demand).

for more info, see the "Overloading functions from the __builtin__
module" here:

    http://effbot.org/zone/librarybook-builtin.htm

</F>








More information about the Python-list mailing list