[IPython-dev] [patch] IPython.set_trace() implemented

Gökhan SEVER gokhansever at gmail.com
Tue Jun 23 12:21:27 EDT 2009


On Tue, Jun 23, 2009 at 11:16 AM, Gökhan SEVER <gokhansever at gmail.com>wrote:

> Note: Cross-posting on IPy devel and Matplotlib-users list.
>
> Hello,
>
> My 8 hours sleep have helped me solve the riddle of IPython pylab entry
> from a regular Python script. Although it is funky and experimental, it
> works just as I have been seeking it to work for months :)
>
> Here take a look at this piece of code:
>
> (Again, the following lines must be modified in /IPython/Shell.py to start
> with pylab each time a request is made for IPython instantiation. To me a
> line can be added into ipy_user_config such as always_pylab =True )
>
>      #user_opts = set([s.replace('-','') for s in argv[:3]])     user_opts
> = set(['pylab'])
>
>
> #!/usr/bin/env python
>
> #import matplotlib.pyplot as plt
> #import numpy as np
> import IPython
>
> ipy = IPython.Shell.start(user_ns=locals())
>
> a = arange(10)           ###<-- I am in IPython -pylab at this point no
> need for np.arange
> plot(a)                        ###<-- or plt.plot(a)
>
> ipy.mainloop()
>
> Later, when I drop into the IPy shell I can go ahead and manipulate my
> figure appropriately. Now whos() works also :)
>
>
> Gökhan


Ondrej,

Now I can completely exit too :)

In [1]: whos
Variable   Type                    Data/Info
--------------------------------------------
a          ndarray                 10: 10 elems, type `int32`, 40 bytes
ipy        IPShellMatplotlibQt4    <IPShellMatplotlibQt4(Thread-1, started)>

In [2]: exit()
Do you really want to exit ([y]/n)? y
*Closing threads... Done.*
[gsever at ccn src]$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20090623/fa0df6ba/attachment.html>


More information about the IPython-dev mailing list