Message187232
It would be nice if there was a `with` "expression". Such that instead of:
with open(...) as f:
result = foo(f)
One could write:
result = foo(f) with open(...) as f
This would be particularly useful in comprehensions. Instead of:
files = {}
for fname in os.listdir('.'):
if predicate(fname):
with open(fname) as f:
files[fname] = foo(f)
files = {
fname: foo(f) with open(fname) as f
for fname in os.listdir('.') if predicate(fname)
} |
|
Date |
User |
Action |
Args |
2013-04-18 10:02:40 | Eric.Wieser | set | recipients:
+ Eric.Wieser |
2013-04-18 10:02:40 | Eric.Wieser | set | messageid: <1366279360.22.0.996047925833.issue17788@psf.upfronthosting.co.za> |
2013-04-18 10:02:40 | Eric.Wieser | link | issue17788 messages |
2013-04-18 10:02:40 | Eric.Wieser | create | |
|