[IPython-User] A robust way to grab the IPython shell reference within a script / module

Thomas Kluyver takowl@gmail....
Thu Mar 15 05:26:53 CDT 2012

On 15 March 2012 09:12, Ludwig Schwardt <ludwig.schwardt@gmail.com> wrote:

>     ip = __builtins__.get('__IPYTHON__')

__builtins__ is sometimes a dictionary and sometimes a module, although I'm
not sure when it changes. Since the builtin namespace should always be
accessible, can you just do "ip = __IPYTHON__" and catch NameError again?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20120315/486c3997/attachment.html 

More information about the IPython-User mailing list