[IPython-dev] RFC: IPython.ipapi for "public" ipython API.

Ville Vainio vivainio at gmail.com
Fri Jan 13 18:59:54 CST 2006


It is accomplished :-D.

In SVN now, here's a "config file" example

-----------------------------------------------
import IPython.ipapi as ip

def ankka_f(self, arg):
    print "Ankka",self,"says uppercase:",arg.upper()

ip.expose_magic("ankka",ankka_f)

ip.magic('alias sayhi echo "Testing, hi ok"')
ip.magic('alias helloworld echo "Hello world"')
ip.system('pwd')

ip.ex('import re')
ip.ex("""
def funcci(a,b):
    print a+b
print funcci(3,4)
""")
ip.ex("funcci(348,9)")

def jed_editor(self,filename, linenum=None):
    print "Calling my own editor, jed ... via hook!"
    import os
    if linenum is None: linenum = 0
    os.system('jed +%d %s' % (linenum, filename))
    print "exiting jed"

ip.set_hook('editor',jed_editor)
print "done!"
--------------------

Just put it in a file and import it... no need to %run/whatever.




More information about the IPython-dev mailing list