[IPython-user] testing if a function was called from the command prompt
Ville M. Vainio
Mon Feb 25 10:22:34 CST 2008
On Mon, Feb 25, 2008 at 6:02 PM, Ryan Krauss <email@example.com> wrote:
> would put a show() command at the end. This is probably not the
> desired behavior when doing interactive stuff at the command prompt.
> Is it possible for me to test in my function whether or not the
> function was called interactively or using the run magic command?
if '_ip' in globals():
> Along with that, it is possible that some of the students will try to
> use idle instead of IPython (they don't always listen to my
> recommendations). Is it possible to test IPython vs. idle?
ip = IPython.ipapi.get()
if ip is None:
print "Go back to IPython, punk!"
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'
More information about the IPython-user