To ease debugging from Ipython, I include the following in the beginning of my scripts
from IPython.Debugger import Tracer
debug = Tracer()
However, if I launch my script from the command line with
$ python myscript.py
I get an error related to Ipython. Is there a way to do the following
if run_from_ipython():
from IPython.Debugger import Tracer
debug = Tracer()
This way I only import the Tracer() function when I need it.