[IPython-user] testing if a function was called from the command prompt

Ryan Krauss ryanlists@gmail....
Mon Feb 25 10:02:29 CST 2008

I am writing a module for my students to use.  Most of them are not
Python experts.  The function will generate a plot using matplotlib's
pylab interface most of the time (unless an optionaly keyword argument
suppressing the plot is set to True).  I just noticed that the
function doesn't update the figure unless I call pylab.show()
afterwards (that probably depends on some settings in matplotlibrc).
This is probably the desired behavior in a script where the students
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?
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?



More information about the IPython-user mailing list