Package csb :: Package io :: Class TempFile
[frames] | no frames]

Class TempFile

source code

object --+    
         |    
core.Proxy --+
             |
            TempFile

Create a temporary file and take care of deleting it upon object destruction. The file can be opened multiple times on any platform, unlike the case with tempfile.NamedTemporaryFile (does not work on Windows).

>>> with TempFile() as tmp:
        tmp.write(...)
        open(tmp.name)...
Instance Methods
 
__del__(self) source code
 
__enter__(self) source code
 
__exit__(self, *args) source code
 
__init__(self, dispose=True, mode='t')
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
close(self)
Flush, close and delete the file.
source code
str or bytes
content(self)
Returns: the current content of the file.
source code

Inherited from core.Proxy: __getattr__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties
str name
Full path and file name

Inherited from object: __class__

Method Details

__init__(self, dispose=True, mode='t')
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • dispose (bool) - automatically delete the file
  • mode - file open mode (text, binary), default=t
Overrides: object.__init__
(inherited documentation)

content(self)

source code 
Returns: str or bytes
the current content of the file.

Property Details

name

Full path and file name

Get Method:
unreachable.name(self) - Full path and file name
Type:
str