Author Nils Kattenbeck
Recipients Anthony Sottile, CAM-Gerlach, Nils Kattenbeck, epicfaace, georg.brandl, maurosr, ncoghlan, nyuszika7h, pitrou, r.david.murray, serhiy.storchaka
Date 2021-05-26.21:08:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1622063332.6.0.528635620878.issue25024@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-05-26 21:08:52Nils Kattenbecksetrecipients: + Nils Kattenbeck, georg.brandl, ncoghlan, pitrou, r.david.murray, serhiy.storchaka, maurosr, Anthony Sottile, epicfaace, CAM-Gerlach, nyuszika7h
2021-05-26 21:08:52Nils Kattenbecksetmessageid: <1622063332.6.0.528635620878.issue25024@roundup.psfhosted.org>
2021-05-26 21:08:52Nils Kattenbecklinkissue25024 messages
2021-05-26 21:08:52Nils Kattenbeckcreate