Is it possible to go into ipython from code?
Question: For my debugging needs, `pdb` is pretty good. However, it would be _much_
cooler (and helpful) if I could go into `ipython`. Is this thing possible?


Answer: There is an `ipdb` project which embeds iPython into the standard pdb, so you
can just do:

    
    
    import ipdb; ipdb.set_trace()
    

It's installable via the usual `easy_install ipdb`.

`ipdb` is pretty short, so instead of easy_installing you can also create a
file `ipdb.py` somewhere on your Python path and paste the following into the
file:

    
    
    import sys
    from IPython.Debugger import Pdb
    from IPython.Shell import IPShell
    from IPython import ipapi
    
    shell = IPShell(argv=[''])
    
    def set_trace():
        ip = ipapi.get()
        def_colors = ip.options.colors
        Pdb(def_colors).set_trace(sys._getframe().f_back)
    

