First time here? Check out the FAQ!

Ask Your Question
1

How to find if computation is in a notebook or sage prompt ?

asked 14 years ago

Pedro gravatar image
  • Example of what is needed in sage prompt:

    sage: is_sageprompt()

    True

  • Example of what is needed in a notebook:

In an input cell: is_sagenotebook()

The output cell: True

Preview: (hide)

Comments

Can you let us know how this would be useful? One of the things we like to do in Sage is make sure there is *not* a difference, so one can use either method, though things like @interact keep this from being 100% true.

kcrisman gravatar imagekcrisman ( 14 years ago )

I would like pretty print some results in both notebook and sage prompt. The comand html('

Big Table

') works fine in notebook but not in sage prompt. I will use html(...) in notebook and "print" in sage prompt.

Pedro gravatar imagePedro ( 14 years ago )

Then using this flag should work fine.

kcrisman gravatar imagekcrisman ( 14 years ago )

1 Answer

Sort by » oldest newest most voted
4

answered 14 years ago

kcrisman gravatar image

There is an env variable of sorts called EMBEDDED_MODE, I think, which is used internally to tell whether one is in the notebook.

----------------------------------------------------------------------
| Sage Version 4.6.2.alpha1, Release Date: 2011-01-20                |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
**********************************************************************
*                                                                    *
* Warning: this is a prerelease version, and it may be unstable.     *
*                                                                    *
**********************************************************************
Loading Sage library. Current Mercurial branch is: plotpatches
sage: sage.plot.plot.EMBEDDED_MODE
False

But in the notebook this will give True.

Preview: (hide)
link

Comments

Nice! It seems to me the natural place for some flag like that would be in notebook.*, which is where I looked for it.

DSM gravatar imageDSM ( 14 years ago )

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: 14 years ago

Seen: 630 times

Last updated: Feb 17 '11