getipython.py
30 lines
| 1.1 KiB
| text/x-python
|
PythonLexer
Brian Granger
|
r2205 | # encoding: utf-8 | ||
MinRK
|
r10579 | """Simple function to call to get the current InteractiveShell instance | ||
Fernando Perez
|
r1414 | """ | ||
#----------------------------------------------------------------------------- | ||||
MinRK
|
r10579 | # Copyright (C) 2013 The IPython Development Team | ||
Brian Granger
|
r2205 | # | ||
# Distributed under the terms of the BSD License. The full license is in | ||||
# the file COPYING, distributed as part of this software. | ||||
Fernando Perez
|
r1414 | #----------------------------------------------------------------------------- | ||
ville
|
r988 | |||
Brian Granger
|
r2205 | #----------------------------------------------------------------------------- | ||
# Imports | ||||
#----------------------------------------------------------------------------- | ||||
Robert Kern
|
r1419 | |||
MinRK
|
r10579 | import warnings | ||
Brian Granger
|
r2205 | #----------------------------------------------------------------------------- | ||
# Classes and functions | ||||
#----------------------------------------------------------------------------- | ||||
Robert Kern
|
r1419 | |||
Brian Granger
|
r2292 | |||
MinRK
|
r10579 | def get_ipython(): | ||
"""Get the global InteractiveShell instance. | ||||
Returns None if no InteractiveShell instance is registered. | ||||
""" | ||||
Brian Granger
|
r2816 | from IPython.core.interactiveshell import InteractiveShell | ||
MinRK
|
r10579 | if InteractiveShell.initialized(): | ||
return InteractiveShell.instance() | ||||