[IPython-user] possible future features

Fernando Perez fperez.net@gmail....
Sun Mar 18 21:44:54 CDT 2007


On 1/10/07, belinda thom <bthom@cs.hmc.edu> wrote:
> Fernando,
>
> I think being able to turn off the -pylab related "from pylab import
> *" would be great, for as others have commented on various related
> lists, there's good reason to force one to be explicit about which
> calls are coming from where.
>
> It seems I might be able to hack Shell.py here to get what I want now:
>
>          exec ("import matplotlib\n"
>                "import matplotlib.pylab as pylab\n"
>                "from matplotlib.pylab import *") in user_ns

I've added this functionality in r2156.  You'll need to add to your
ipythonrc file this flag:

pylab_import_all 0

if you want to disable the 'import *' part.

The default value for this is still True, because at this point I am
NOT going to break backwards compatibility with existing pylab usage.

> But this brings up another thing that would be really nice --- the
> ability to clear the user namespace in a way beyond what %reset does
> (touching more than just what %who shows) --- something akin to the
> "Run" (F5) command that IDLE has when running w/o the -n option? I
> can quit IPython and restart, but that feels messy (and it requires a
> bit more work when using py-shell in emacs).

You may want to try calling

_ip.user_ns.clear()

to see if this satisfies you.  It's worth noting that IDLE's F5
actually starts a wholesale python process:

>>> ================================ RESTART ================================
>>>
My PID is: 23167
>>> ================================ RESTART ================================
>>>
My PID is: 23171
>>> ================================ RESTART ================================
>>>
My PID is: 23174
>>>

This is precisely what you DON'T want when the imports atop the code
you are testing take 1 minute to execute (such as what running 'import
itk' takes even on a fairly fast system).


Cheers,

f


More information about the IPython-user mailing list