I wrote a small piece of python code which i use as a module in python as well as in a worksheet in sage notebook. Since this script uses pyplot i'd like to do something like
if in_notebook: pyplot.savefig('fig')
else: pyplot.show()
How can i find out where the script is running in?