getipython.py 916 B

123456789101112131415161718192021222324
  1. # encoding: utf-8
  2. """Simple function to call to get the current InteractiveShell instance
  3. """
  4. #-----------------------------------------------------------------------------
  5. # Copyright (C) 2013 The IPython Development Team
  6. #
  7. # Distributed under the terms of the BSD License. The full license is in
  8. # the file COPYING, distributed as part of this software.
  9. #-----------------------------------------------------------------------------
  10. #-----------------------------------------------------------------------------
  11. # Classes and functions
  12. #-----------------------------------------------------------------------------
  13. def get_ipython():
  14. """Get the global InteractiveShell instance.
  15. Returns None if no InteractiveShell instance is registered.
  16. """
  17. from IPython.core.interactiveshell import InteractiveShell
  18. if InteractiveShell.initialized():
  19. return InteractiveShell.instance()