[Tutor] Does IPython have a "restart"?

Dick Moores rdm at rcblue.com
Thu Jul 17 09:08:04 CEST 2008

At 07:55 AM 7/16/2008, Dick Moores wrote:
>I mean something equivalent to what you get when you do a Ctrl+F6 in IDLE:
> >>> import math
> >>> math.log(3)
> >>> =============================================== RESTART 
> ===============================================
> >>> math.log(3)
>Traceback (most recent call last):
>   File "<pyshell#9>", line 1, in <module>
>     math.log(3)
>NameError: name 'math' is not defined
> >>>

Got this from the ipython-user list:

Use %reset:

In [1]: import math

In [2]: math.sin(3)
Out[2]: 0.14112000805986721

In [3]: %reset
Once deleted, variables cannot be recovered. Proceed (y/[n])?  y

In [5]: math.sin(3)
NameError                                 Traceback (most recent call last)

/home/fperez/Desktop/<ipython console> in <module>()

NameError: name 'math' is not defined

Note that it is  NOT the same though: idle forces a new, fresh python
process, while ipython just clears your current variables.  So things
like reloading extension modules won't work the same way.


More information about the Tutor mailing list