Message118448
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:
... |
|
Date |
User |
Action |
Args |
2010-10-12 17:49:42 | giampaolo.rodola | set | recipients:
+ giampaolo.rodola, ncoghlan, pitrou, vstinner, hniksic, eric.araujo, r.david.murray, michael.foord, daniel.urban |
2010-10-12 17:49:41 | giampaolo.rodola | set | messageid: <1286905781.95.0.721520804393.issue10049@psf.upfronthosting.co.za> |
2010-10-12 17:49:40 | giampaolo.rodola | link | issue10049 messages |
2010-10-12 17:49:39 | giampaolo.rodola | create | |
|