Ask Your Question
0

How to if python script runs in notebook?

asked 2012-01-27 11:30:53 +0200

buergi gravatar image

updated 2012-01-27 11:32:43 +0200

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 12:56:15 +0200

Kabi gravatar image

updated 2012-01-27 12:57:23 +0200

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 11:30:53 +0200

Seen: 242 times

Last updated: Jan 27 '12