Ask Your Question
0

How to if python script runs in notebook?

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

buergi gravatar image

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

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

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

Kabi gravatar image

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

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

Stats

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

Seen: 173 times

Last updated: Jan 27 '12