The namespace for builtin functions?
Peter Hansen
peter at engcorp.com
Sat Nov 29 18:35:10 EST 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)
Try this instead:
_builtin_apply = apply
def apply(func, seq):
return _builtin_apply(func, seq)
But as Jay says, you're probably better off just not using
the same name...
-Peter
More information about the Python-list
mailing list