Message281180
ExitStack() already covers the "null ctx mgr" use case described in the first message. Original example:
with transaction or contextlib.null():
...
By using ExitStack:
with transaction or ExitStack():
...
You can push this further and do this, which is even more flexible:
with ExitStack() as stack:
if condition:
stack.enter_context(transaction)
...
So ExitStack really is better than the original proposal which could have made sense 6 years ago but not anymore. |
|
Date |
User |
Action |
Args |
2016-11-18 23:30:19 | giampaolo.rodola | set | recipients:
+ giampaolo.rodola, georg.brandl, rhettinger, ncoghlan, pitrou, vstinner, hniksic, eric.araujo, r.david.murray, michael.foord, daniel.urban, piotr.dobrogost, Alexander.Jones, DLitz, Martin Blais |
2016-11-18 23:30:19 | giampaolo.rodola | set | messageid: <1479511819.3.0.40199801098.issue10049@psf.upfronthosting.co.za> |
2016-11-18 23:30:19 | giampaolo.rodola | link | issue10049 messages |
2016-11-18 23:30:19 | giampaolo.rodola | create | |
|