def NamedTemporaryFile(mode='w+b', bufsize=(-1), suffix='', prefix=template, dir=None, delete=True):
 if (dir is None):
  dir = gettempdir()
 if ('b' in mode):
  flags = _bin_openflags
 else:
  flags = _text_openflags
 if ((_os.name == 'nt') and delete):
  flags |= _os.O_TEMPORARY
 (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
 try:
  file = _os.fdopen(fd, mode, bufsize)
  return _TemporaryFileWrapper(file, name, delete)
 except BaseException:
  _os.unlink(name)
  _os.close(fd)
  raise

def NamedTemporaryFile ( mode = 'w+b' , bufsize = ( - 1 ) , suffix = '' , prefix = template , dir = None , delete = True ) : if ( dir is None ) : dir = gettempdir ( ) if ( 'b' in mode ) : flags = _bin_openflags else : flags = _text_openflags if ( ( _os . name == 'nt' ) and delete ) : flags |= _os . O_TEMPORARY ( fd , name ) = _mkstemp_inner ( dir , prefix , suffix , flags ) try : file = _os . fdopen ( fd , mode , bufsize ) return _TemporaryFileWrapper ( file , name , delete ) except BaseException : _os . unlink ( name ) _os . close ( fd ) raise
create and return a temporary file .