This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author giampaolo.rodola
Recipients daniel.urban, eric.araujo, giampaolo.rodola, hniksic, michael.foord, ncoghlan, pitrou, r.david.murray, vstinner
Date 2010-10-12.17:49:39
SpamBayes Score 0.00068654615
Marked as misclassified No
Message-id <1286905781.95.0.721520804393.issue10049@psf.upfronthosting.co.za>
In-reply-to
Content
I'm with Antoine. Why not just do this in the context function itself?
I think it's more explicit and easier than reading the doc to figure out what nullcontext is supposed to do:


from contextlib import contextmanager

CONDITION = False

@contextmanager
def transaction():
    if not CONDITION:
        yield None
    else:
        yield ...

with transaction() as x:
    ...
History
Date User Action Args
2010-10-12 17:49:42giampaolo.rodolasetrecipients: + giampaolo.rodola, ncoghlan, pitrou, vstinner, hniksic, eric.araujo, r.david.murray, michael.foord, daniel.urban
2010-10-12 17:49:41giampaolo.rodolasetmessageid: <1286905781.95.0.721520804393.issue10049@psf.upfronthosting.co.za>
2010-10-12 17:49:40giampaolo.rodolalinkissue10049 messages
2010-10-12 17:49:39giampaolo.rodolacreate