[issue22387] Making tempfile.NamedTemporaryFile a class
Antony Lee
report at bugs.python.org
Thu Sep 11 11:24:08 CEST 2014
Antony Lee added the comment:
The initial idea was to solve #14243 (NamedTemporaryFile would be more useful on Windows if you could close it without deleting) by adding a "closed" keyword argument to the constructor of a subclass, that would set "delete" to False and then close it, e.g.
class NTF(NamedTemporaryFile):
def __init__(self, *args, closed=False, **kwargs):
if closed: kwargs["delete"] = True
super().__init__(*args, **kwargs)
if closed: self.close()
Actually, there are some not-so-nice interactions with the context-manager protocol though, as the file cannot be reopened. So it's not clear that this is such a good idea.
Still, it somewhat confusing that a CamelCase object is not actually a type (especially when TemporaryDirectory is one).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22387>
_______________________________________
More information about the Python-bugs-list
mailing list