##// END OF EJS Templates
jobctrl: use shell if the command line has shell control chars (|><), so that "bzr log | less" etc. work
jobctrl: use shell if the command line has shell control chars (|><), so that "bzr log | less" etc. work

File last commit:

r988:2f09c2ab
r1034:4eb1954e
Show More
test_embed.py
32 lines | 882 B | text/x-python | PythonLexer
""" An example of one way to embed IPython in your own application
This basically means starting up IPython with some of your programs objects visible in the IPython
user namespace.
"""
import sys
sys.path.append('..')
import IPython.ipapi
my_ns = dict(a=10)
ses = IPython.ipapi.make_session(my_ns)
# Now get the ipapi instance, to be stored somewhere in your program for manipulation of the running
# IPython session. See http://ipython.scipy.org/moin/IpythonExtensionApi
ip = ses.IP.getapi()
# let's play with the ipapi a bit, creating a magic function for a soon-to-be-started IPython
def mymagic_f(self,s):
print "mymagic says",s
ip.expose_magic("mymagic",mymagic_f)
# And finally, start the IPython interaction! This will block until you say Exit.
ses.mainloop()
print "IPython session finished! namespace content:",my_ns