##// END OF EJS Templates
add zero-import get_ipython example
MinRK -
Show More
@@ -70,7 +70,17 b' We also have added:'
70 Which is a *library* function for getting the current IPython instance,
70 Which is a *library* function for getting the current IPython instance,
71 and will return ``None`` if no IPython instance is running.
71 and will return ``None`` if no IPython instance is running.
72 This is the official way to check whether your code is called from inside an IPython session.
72 This is the official way to check whether your code is called from inside an IPython session.
73 If you want to check for IPython without unnecessarily importing IPython,
74 use this function:
73
75
76 .. sourcecode:: python
77
78 def get_ipython():
79 """return IPython instance if there is one, None otherwise"""
80 import sys
81 if "IPython" in sys.modules:
82 import IPython
83 return IPython.get_ipython()
74
84
75 Core
85 Core
76 ----
86 ----
General Comments 0
You need to be logged in to leave comments. Login now