On Tue, Jun 23, 2009 at 11:16 AM, Gökhan SEVER <span dir="ltr"><<a href="mailto:gokhansever@gmail.com">gokhansever@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

Note: Cross-posting on IPy devel and Matplotlib-users list.<br><br>Hello,<br><br>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 :)<br>

<br>Here take a look at this piece of code:<br><br>(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 )<div class="im">
<br>
<br>     #user_opts = set([s.replace('-','') for s in argv[:3]])<div class="gmail_quote"><div>     user_opts = set(['pylab'])<font color="#888888"><br>
</font></div></div><br><br></div>#!/usr/bin/env python<br><br>#import matplotlib.pyplot as plt<br>#import numpy as np<br>import IPython<br><br>ipy = IPython.Shell.start(user_ns=locals())<br><br>a = arange(10)           ###<-- I am in IPython -pylab at this point no need for np.arange <br>

plot(a)                        ###<-- or plt.plot(a)<br><br>ipy.mainloop()<br><br>Later, when I drop into the IPy shell I can go ahead and manipulate my figure appropriately. Now whos() works also :)<br><font color="#888888"><br>
<br>Gökhan</font></blockquote><div><br>Ondrej,<br><br>Now I can completely exit too :)<br><br>In [1]: whos<br>Variable   Type                    Data/Info<br>--------------------------------------------<br>a          ndarray                 10: 10 elems, type `int32`, 40 bytes<br>
ipy        IPShellMatplotlibQt4    <IPShellMatplotlibQt4(Thread-1, started)><br><br>In [2]: exit()<br>Do you really want to exit ([y]/n)? y<br><b>Closing threads... Done.</b><br>[gsever@ccn src]$ <br> <br></div></div>
<br>