finalize(obj, func, *args, **kwargs)¶
Class for finalization of weakrefable objects
finalize(obj, func, *args, **kwargs) returns a callable finalizer object which will be called when obj is garbage collected. The first time the finalizer is called it evaluates func(*arg, **kwargs) and returns the result. After this the finalizer is dead, and calling it just returns None.
When the program exits any remaining finalizers for which the atexit attribute is true will be run in reverse order of creation. By default atexit is true.
Whether finalizer is alive
Whether finalizer should be called at exit
If alive then mark as dead and return (obj, func, args, kwargs); otherwise return None
If alive then return (obj, func, args, kwargs); otherwise return None
NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, delete=True, wrapper_class_override=None)¶
Create and return a temporary file. Arguments: ‘prefix’, ‘suffix’, ‘dir’ – as for mkstemp. ‘mode’ – the mode argument to io.open (default “w+b”). ‘buffering’ – the buffer size argument to io.open (default -1). ‘encoding’ – the encoding argument to io.open (default None) ‘newline’ – the newline argument to io.open (default None) ‘delete’ – whether the file is deleted on close (default True). The file is created as mkstemp() would do it. Returns an object with a file-like interface; the name of the file is accessible as its ‘name’ attribute. The file will be automatically deleted when it is closed unless the ‘delete’ argument is set to False.