@contextlib.contextmanager
def create_tempfile(content=None):
 (fd, tmp) = tempfile.mkstemp()
 if content:
  if (sys.version_info >= (3, 0)):
   os.write(fd, bytes(content, 'ascii'))
  else:
   os.write(fd, content)
 try:
  (yield tmp)
 finally:
  os.close(fd)
  os.remove(tmp)

@ contextlib . contextmanager def create_tempfile ( content = None ) : ( fd , tmp ) = tempfile . mkstemp ( ) if content : if ( sys . version_info >= ( 3 , 0 ) ) : os . write ( fd , bytes ( content , 'ascii' ) ) else : os . write ( fd , content ) try : ( yield tmp ) finally : os . close ( fd ) os . remove ( tmp )
create a new temporary file .