"Moore, Paul" <Paul.Moore@atosorigin.com> writes: > From: Michael Hudson [mailto:mwh@python.net] >>>> How would I do this elegantly without the assignment...? >>> >>> Just as you do with if: >> >> Good point. "with" testlist ':' NEWLINE it is, if it's me >> that gets to write the PEP. > > Are you saying that you don't see the value of > > with var = expr: > suite > > because it can be rewritten as > > var = expr > with var: > suite > > ? Hmm, I suppose so. Well, I'd consider making the "var =" optional, but that would require hairy parser games (I think it would be possible, but very nasty). Given that it (practically) can't be, I find having to make up a name for something that doesn't need one (e.g. with dummy = autolock(lock): ... ) more unpleasant than having to bind to a name in a different line. [...] > So I guess what I'm saying is that "with ... autoclose" only > make sense in combination. Putting the two on different lines loses > that connection. If you need to name the result of the autoclose() > call, you either allow the with construct to include the assignment, > or you lose that conceptual link. Hmm, maybe the nasty parser hacks would be worth it... Cheers, M. -- 8. A programming language is low level when its programs require attention to the irrelevant. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4