Re: [Python-Dev] exec/with thunk-handling proposal
3 Feb
2003
3 Feb
'03
4:12 p.m.
From: "Gerald S. Williams"
holger krekel wrote: I think we can may get away with only a "weak" keyword and allow the aforementioned encapsulation of execution events into an object like this:
exec expr [with params]: suite
I was about to propose something similar. This looks like it can be unified with what Guido proposed.
regards and interested in comments,
An observation:
Used like this, "with" looks like an alias for "lambda" (providing default values for all parameters).
Yes. If we have multiline lambda, we could write: def autoclose(f, action): try: action(f) finally: f.close() autoclose(open("blah.txt"), lambda f: for line in f: print line )
7752
Age (days ago)
7752
Last active (days ago)
0 comments
1 participants
participants (1)
-
jo@jan.csie.ntu.edu.tw