Nicolas Fleury wrote: > def getFirstLine(filename): > with opening(filename) as file > return file.readline()
Your tastes definitely disagree with the majority of Python programmers then, including Guido. Scoping is defined in Python by indentation. If you want the above sort of thing, you're going to have to write a new PEP, and I'd be very surprised to see it accepted. But there's nothing stopping you from doing so. > def getFirstLine(filename): > with opening(filename) as file: > return file.readline() This is beautiful and explicit. What else could you want? The syntax: with EXPR1 as VAR1, EXPR2 as VAR2: ... was discussed on python-dev. It wasn't explicitly rejected, but the feeling seemed to be that it was an unnecessary complication as far as PEP 343 is concerned. There's nothing stopping another PEP proposing this as an extension to PEP 343, and there's nothing stopping that being in Python 2.5 if it's accepted. PEP 343 was originally PEP 340 (and several other things) and was quite complicated at one point (it originally contained PEP 342 as well). The PEP in its current state represents 2 months of discussion, complication and (finally) simplification. Its semantics are clear and unambiguous. And (as Guido states) it will obsolete 4(?) other PEPs. Be sure to read the referenced PEPs (and the ones referenced from them) - they contain a lot of history. Also read PEP 346 for a competing PEP to PEPs 340 and 343 that gradually converged to PEP 343 - most importantly, it contains the rejected options (that seem to have been lost from PEPs 340 and 343). Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list