code: def tmpfile(*args, **kwargs):
      
      (fd, fname) = tempfile.mkstemp(*args, **kwargs)
      try:
          yield fname
      finally:
          os.close(fd)
          if os.path.exists(fname):
              os.remove(fname)
docs: Make a tempfile, safely cleaning up file descriptors on completion.