code: def _get_globals():
      
      if _get_globals_callback is not None:
          return _get_globals_callback()
      else:
          try:
              from __main__ import __dict__ as namespace
          except ImportError:
              try:
                  # The import fails on IronPython
                  import __main__
                  namespace = __main__.__dict__
              except:
                  namespace
          shell = namespace.get('__ipythonshell__')
          if shell is not None and hasattr(shell, 'user_ns'):
              # IPython 0.12+ kernel
              return shell.user_ns
          else:
              # Python interpreter
              return namespace
          return namespace
docs: Return current Python interpreter globals namespace