Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Recovering an overwritten Sage built-in name

In Python 2.7, if you accidentally overwrite a builtin name (eg max, str, int, ...), you can recover it by calling the __builtins__ module :

>>> max(2020, 42)
2020
>>> max=2038
>>> max(2020, 42)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable
>>> max=__builtins__.max
>>> max(2020, 42)
2020
>>>

What is the equivalent for Sage built-in names (there are about 2000 so accident can occur) ? For instance, imagine I overwrite the complex number I :

sage: I=42

How can I recover it ?