code: def open_output(self, fname):
          
  
          if not fname:
              return (sys.stdout, False)
          elif isinstance(fname, str):
              return (file(fname, "wb"), True)
          else:
              if not hasattr(fname, "write"):
                  raise Exception("Expecting either a filename or a file-like object, but got %s" % fname)
              return (fname, False)
docs: Open the output file FNAME. Returns tuple (FD, NEED_CLOSE),
          where FD is a file (or file-like) object, and NEED_CLOSE is a
          boolean flag that tells whether FD.close() should be called
          after finishing writing to the file.
  
          FNAME can be one of the three things:
          (1) None, in which case (sys.stdout, False) is returned.
          (2) A file-like object, in which case (fname, False) is returned.
          (3) A string, in which case this procedure opens the file and returns
          (fd, True).