old_contents: import matplotlib as mpl
  import matplotlib.pyplot as plt
  import os
  import sys
  
  mpl.rc('text', usetex=True)
  mpl.rc('font', family='serif', size=12)
  
  
  def save(path, fignum=None, close=True, width=None, height=None,
           ext=None, verbose=False):
      """Save a figure from pyplot.
  
      Parameters:
  
      path [string] : The path (and filename, without the extension) to
      save the figure to.
  
      fignum [integer] : The id of the figure to save. If None, saves the
      current figure.
  
      close [boolean] : (default=True) Whether to close the figure after
      saving.  If you want to save the figure multiple times (e.g., to
      multiple formats), you should NOT close it in between saves or you
      will have to re-plot it.
  
      width [number] : The width that the figure should be saved with. If
      None, the current width is used.
  
      height [number] : The height that the figure should be saved with. If
      None, the current height is used.
  
      ext [string or list of strings] : (default='png') The file
      extension. This must be supported by the active matplotlib backend
      (see matplotlib.backends module).  Most backends support 'png',
      'pdf', 'ps', 'eps', and 'svg'.
  
      verbose [boolean] : (default=True) Whether to print information
      about when and where the image has been saved.
  
      """
  
      # make sure we have a list of extensions
      if not hasattr(ext, '__iter__'):
          ext = [ext]
  
      # Extract the directory and filename from the given path
      directory, basename = os.path.split(path)
      if directory == '':
          directory = '.'
  
      # If the directory does not exist, create it
      if not os.path.exists(directory):
          os.makedirs(directory)
  
      for ex in ext:
          # The final path to save to
          filename = "%s.%s" % (basename, ex)
          savepath = os.path.join(directory, filename)
  
          if verbose:
              sys.stdout("Saving figure to '%s'..." % savepath)
  
          # Actually save the figure
          plt.savefig(savepath)
  
      # Close it
      if close:
          plt.close()
  
      if verbose:
          sys.stdout("Done\n")
  
new_contents: import matplotlib as mpl
  import matplotlib.pyplot as plt
  import os
  import sys
  
  mpl.rc('text', usetex=True)
  mpl.rc('font', family='serif', size=12)
  
  
  def save(path, fignum=None, close=True, width=None, height=None,
           ext=None, verbose=False):
      """Save a figure from pyplot.
  
      Parameters:
  
      path [string] : The path (and filename, without the extension) to
      save the figure to.
  
      fignum [integer] : The id of the figure to save. If None, saves the
      current figure.
  
      close [boolean] : (default=True) Whether to close the figure after
      saving.  If you want to save the figure multiple times (e.g., to
      multiple formats), you should NOT close it in between saves or you
      will have to re-plot it.
  
      width [number] : The width that the figure should be saved with. If
      None, the current width is used.
  
      height [number] : The height that the figure should be saved with. If
      None, the current height is used.
  
      ext [string or list of strings] : (default='png') The file
      extension. This must be supported by the active matplotlib backend
      (see matplotlib.backends module).  Most backends support 'png',
      'pdf', 'ps', 'eps', and 'svg'.
  
      verbose [boolean] : (default=True) Whether to print information
      about when and where the image has been saved.
  
      """
  
      # make sure we have a list of extensions
      if not hasattr(ext, '__iter__'):
          ext = [ext]
  
      # Extract the directory and filename from the given path
      directory, basename = os.path.split(path)
      if directory == '':
          directory = '.'
  
      # If the directory does not exist, create it
      if not os.path.exists(directory):
          os.makedirs(directory)
  
      for ex in ext:
          # The final path to save to
          filename = "%s.%s" % (basename, ex)
          savepath = os.path.join(directory, filename)
  
          if verbose:
              sys.stdout.write("Saving figure to '%s'..." % savepath)
  
          # Actually save the figure
          plt.savefig(savepath)
  
      # Close it
      if close:
          plt.close()
  
      if verbose:
          sys.stdout.write("Done\n")
  
subject: Fix bug with sys.stdout