Ask Your Question

Revision history [back]

Is there an existing function detecting the use of the notebook ?

I would like to know whether the user is using the notebook or the command line, in order to behave differently depending on that (for example to output links in html or text). The following works but is a bit hackish:

def is_notebook():
    sagenb.misc.support.automatic_names(True)
    try:
        _automatic_names
    except NameError:
        return False
    else:
        return True

Is there an existing function that does the job in sage ?