[IPython-User] detect if the script is under ipython
Sun Nov 27 21:29:30 CST 2011
On Sun, Nov 27, 2011 at 7:21 PM, Tom Bennett <firstname.lastname@example.org> wrote:
> I am wondering if there is a way to detect if a script is under ipython
> 0.12. __IPYTHON__ no longer works.
Sorry about that... There is now a numerical flag, __IPYTHON__active,
that you can test for. It tries to count the levels of nesting of
IPython, but honestly I think that in the long run we should go for
something much simpler: just a flag, called __IPYTHON__ whose presence
indicates IPython is active and that we delete when we exit. Since
now we have not only terminal interaction but also event-driven
kernels (on zmq), I think it's a bit hopeless to try to track levels
of nesting correctly. A very simple flag, set in the builtins when
the object is initialized, is probably all we should have. Anything
else is bound to be brittle and likely to hurt more than it helps.
More information about the IPython-User