def embed(**kwargs):
 config = kwargs.get('config')
 header = kwargs.pop('header', u'')
 compile_flags = kwargs.pop('compile_flags', None)
 if (config is None):
  config = load_default_config()
  config.InteractiveShellEmbed = config.TerminalInteractiveShell
  kwargs['config'] = config
 ps1 = None
 ps2 = None
 try:
  ps1 = sys.ps1
  ps2 = sys.ps2
 except AttributeError:
  pass
 saved_shell_instance = InteractiveShell._instance
 if (saved_shell_instance is not None):
  cls = type(saved_shell_instance)
  cls.clear_instance()
 frame = sys._getframe(1)
 shell = InteractiveShellEmbed.instance(_call_location_id=('%s:%s' % (frame.f_code.co_filename, frame.f_lineno)), **kwargs)
 shell(header=header, stack_depth=2, compile_flags=compile_flags)
 InteractiveShellEmbed.clear_instance()
 if (saved_shell_instance is not None):
  cls = type(saved_shell_instance)
  cls.clear_instance()
  for subclass in cls._walk_mro():
   subclass._instance = saved_shell_instance
 if (ps1 is not None):
  sys.ps1 = ps1
  sys.ps2 = ps2

def embed ( ** kwargs ) : config = kwargs . get ( 'config' ) header = kwargs . pop ( 'header' , u'' ) compile_flags = kwargs . pop ( 'compile_flags' , None ) if ( config is None ) : config = load_default_config ( ) config . InteractiveShellEmbed = config . TerminalInteractiveShell kwargs [ 'config' ] = config ps1 = None ps2 = None try : ps1 = sys . ps1 ps2 = sys . ps2 except AttributeError : pass saved_shell_instance = InteractiveShell . _instance if ( saved_shell_instance is not None ) : cls = type ( saved_shell_instance ) cls . clear_instance ( ) frame = sys . _getframe ( 1 ) shell = InteractiveShellEmbed . instance ( _call_location_id = ( '%s:%s' % ( frame . f_code . co_filename , frame . f_lineno ) ) , ** kwargs ) shell ( header = header , stack_depth = 2 , compile_flags = compile_flags ) InteractiveShellEmbed . clear_instance ( ) if ( saved_shell_instance is not None ) : cls = type ( saved_shell_instance ) cls . clear_instance ( ) for subclass in cls . _walk_mro ( ) : subclass . _instance = saved_shell_instance if ( ps1 is not None ) : sys . ps1 = ps1 sys . ps2 = ps2
embeds existing plotly figure in ipython notebook plotly uniquely identifies figures with a file_owner/file_id pair .