Package shelljob :: Module fs :: Class NamedTempFile
[hide private]
[frames] | no frames]

Class NamedTempFile

source code

Creates a temporary file for a 'with' block. The file is deleted when the block exits. This creates the file to ensure it exists/block a race, but does not write anything to it, nor does it keep it open. It is intended for times when you need a named file for subprocesses.


       with fs.NamedTempFile() as nm:
      "curl -o {}".format( nm ) )
               html = open(nm).read()
               print( len(html) )
Instance Methods [hide private]
__init__(self, suffix=None, prefix=None, dir=None) source code
__enter__(self) source code
__exit__(self, type, value, traceback) source code
Method Details [hide private]

__init__(self, suffix=None, prefix=None, dir=None)

source code 
  • suffix - optional suffix for generated filename (a dot '.' is not automatically added, specifiy it if desired)
  • prefix - optional prefix for generated filename
  • dir - in which directory, if None then use a system default