Nils Kattenbeck <[email protected]> added the comment:
While the proposal linked by C.A.M. solves one of the use cases but it does not
address the others.
One use cases which is rather common for me it is e.g. to have scripts/programs
which allow configuring whether temporary directories should get deleted or
stay persistent after program exit.
Currently this always requires hand rolled wrappers like the following:
def mkdtemp_persistent(*args, persistent=True, **kwargs):
if persistent:
@contextmanager
def normal_mkdtemp():
yield tempfile.mkdtemp()
return normal_mkdtemp(*args, **kwargs)
else:
return tempfile.TemporaryDirectory(*args, **kwargs)
with mkdtemp_persistent(persistent=False) as dir:
...
Which gets the job done but is not as user friendly as other parts of the
stdlib.
----------
nosy: +Nils Kattenbeck
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue25024>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com