Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to if python script runs in notebook?

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?

How to if python script runs in notebook?

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?

At the moment i'm querying sys.executable, but i guess this can be done better.