Message175656
After seeing a context manager named like "TempfileIfNeeded(..., cond)", whole sole purpose is to handle the conditional case, I'm firmly +1 on this proposal.
It's much easier to just read "with Tempfile() if cond else nullcontext():" than to read through another level of indirection every time someone wanted some conditional logic on a context manager.
Is there any chance that this issue could be reopened?
Perhaps a more elegant solution would be to modify the "with" statement so that any object can be given to it (then we could just use None directly), but I suspect that would be a tad more controversial. ;) |
|
Date |
User |
Action |
Args |
2012-11-15 23:23:47 | DLitz | set | recipients:
+ DLitz, georg.brandl, rhettinger, ncoghlan, pitrou, vstinner, giampaolo.rodola, hniksic, eric.araujo, r.david.murray, michael.foord, daniel.urban, Alexander.Jones |
2012-11-15 23:23:47 | DLitz | set | messageid: <1353021827.02.0.729037555595.issue10049@psf.upfronthosting.co.za> |
2012-11-15 23:23:47 | DLitz | link | issue10049 messages |
2012-11-15 23:23:46 | DLitz | create | |
|