[IPython-dev] test from where a module is imported
Johann Rohwer
jr at sun.ac.za
Fri Jul 18 06:41:39 EDT 2014
Hi Matthias
Thanks for your reply!
On Friday 18 July 2014 12:25:57 Matthias Bussonnier wrote:
> Le 16 juil. 2014 à 16:19, Johann Rohwer a écrit :
> > Hi all,
> >
> > Say I'm developing a Python module and would like to know from where the
> > user imports this module, i.e.
> >
> > from a regular Python shell, an IPython shell,
>
> in main namesapace, that's easy check fro __IPYTHON__
> or even get_ipython() to get a handle in current runnig process.
Thanks, I had come across these as well, good to know that this is the way to
go.
> > an
> > IPython qtconsole, or an IPython notebook.
>
> You cannot distinguish, and it does not make sense to try to distinguish
> theses. Hence we do not plan to add capability do distinguish. (Plenty of
> description on why on the ML archive)
OK good to know.
> > I would like to enable additional
> >
> > features in my module depending on e.g. useful stuff that is available in
> > the notebook. But I want the module also to be able to be imported and
> > run in any of the other environments, so it's really more like a test
> > from where we are imported.
>
> What are you exactly trying to do ?
We are developing an application that uses Notebook widgets to interactively
manipulate matplotlib graphs (turn lines on and off, etc.). When not running
the notebook, these widgets are therefore not available, but the graph should
nevertheless be displayed, perhaps with a warning to the user to call the
underlying class methods directly since the widget buttons are not there. Here
the qtconsole would be fundamentally different from the notebook: although you
can have the matplotlib graphs inline there would not be widgets available to
manipulate them.
Johann
The integrity and confidentiality of this email is governed by these terms / Hierdie terme bepaal die integriteit en vertroulikheid van hierdie epos. http://www.sun.ac.za/emaildisclaimer
More information about the IPython-dev
mailing list