##// END OF EJS Templates
ipapi.get now returns None if there are no InteractiveShells running....
Brian Granger -
Show More
@@ -1,35 +1,38 b''
1 1 #!/usr/bin/env python
2 2 # encoding: utf-8
3 3 """
4 4 This module is *completely* deprecated and should no longer be used for
5 5 any purpose. Currently, we have a few parts of the core that have
6 6 not been componentized and thus, still rely on this module. When everything
7 7 has been made into a component, this module will be sent to deathrow.
8 8 """
9 9
10 10 #-----------------------------------------------------------------------------
11 11 # Copyright (C) 2008-2009 The IPython Development Team
12 12 #
13 13 # Distributed under the terms of the BSD License. The full license is in
14 14 # the file COPYING, distributed as part of this software.
15 15 #-----------------------------------------------------------------------------
16 16
17 17 #-----------------------------------------------------------------------------
18 18 # Imports
19 19 #-----------------------------------------------------------------------------
20 20
21 from IPython.core.error import TryNext, UsageError
21 from IPython.core.error import TryNext, UsageError, IPythonCoreError
22 22
23 23 #-----------------------------------------------------------------------------
24 24 # Classes and functions
25 25 #-----------------------------------------------------------------------------
26 26
27
27 28 def get():
28 29 """Get the most recently created InteractiveShell instance."""
29 30 from IPython.core.iplib import InteractiveShell
30 31 insts = InteractiveShell.get_instances()
32 if len(insts)==0:
33 return None
31 34 most_recent = insts[0]
32 35 for inst in insts[1:]:
33 36 if inst.created > most_recent.created:
34 37 most_recent = inst
35 38 return most_recent
General Comments 0
You need to be logged in to leave comments. Login now