def mpl_runner(safe_execfile):
 def mpl_execfile(fname, *where, **kw):
  'matplotlib-aware wrapper around safe_execfile.\n\n        Its interface is identical to that of the :func:`execfile` builtin.\n\n        This is ultimately a call to execfile(), but wrapped in safeties to\n        properly handle interactive rendering.'
  import matplotlib
  import matplotlib.pyplot as plt
  is_interactive = matplotlib.rcParams['interactive']
  matplotlib.interactive(False)
  safe_execfile(fname, *where, **kw)
  matplotlib.interactive(is_interactive)
  if plt.draw_if_interactive.called:
   plt.draw()
   plt.draw_if_interactive.called = False
  try:
   da = plt.draw_all
  except AttributeError:
   pass
  else:
   da()
 return mpl_execfile

def mpl_runner ( safe_execfile ) : def mpl_execfile ( fname , * where , ** kw ) : import matplotlib import matplotlib . pyplot as plt is_interactive = matplotlib . rcParams [ 'interactive' ] matplotlib . interactive ( False ) safe_execfile ( fname , * where , ** kw ) matplotlib . interactive ( is_interactive ) if plt . draw_if_interactive . called : plt . draw ( ) plt . draw_if_interactive . called = False try : da = plt . draw_all except AttributeError : pass else : da ( ) return mpl_execfile
factory to return a matplotlib-enabled runner for %run .