Recover handle to shadowed builtin?

Peter Otten __peter__ at web.de
Wed Jan 8 15:24:37 EST 2014


Roy Smith wrote:

> I'm working with ipython's pylab mode, which replaces the builtin sum()
> with the one from numpy:
> 
> In [105]:
> sum
> 
> Out[105]:
> <function numpy.core.fromnumeric.sum>
> 
> Is there any way to recover a reference to the builtin sum()?

>>> from numpy import *
>>> sum
<function sum at 0x7fb99782cc08>
>>> del sum
>>> sum
<built-in function sum>

Doing it more than once does no harm:

>>> del sum
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'sum' is not defined
>>> sum
<built-in function sum>





More information about the Python-list mailing list