@contextmanager
def temporary_file(suffix=''):
 tempfile_stream = NamedTemporaryFile(suffix=suffix, delete=False)
 tempfile = tempfile_stream.name
 tempfile_stream.close()
 (yield tempfile)
 os.remove(tempfile)

@ contextmanager def temporary_file ( suffix = '' ) : tempfile_stream = NamedTemporaryFile ( suffix = suffix , delete = False ) tempfile = tempfile_stream . name tempfile_stream . close ( ) ( yield tempfile ) os . remove ( tempfile )
this is a cross platform temporary file creation .