Ask Your Question

How to if python script runs in notebook?

asked 2012-01-27 04:30:53 -0600

buergi gravatar image

updated 2012-01-27 04:32:43 -0600

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')

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-01-27 05:56:15 -0600

Kabi gravatar image

updated 2012-01-27 05:57:23 -0600

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-01-27 04:30:53 -0600

Seen: 212 times

Last updated: Jan 27 '12