For review: PEP 343: Anonymous Block Redux and Generator Enhancements

Nicolas Fleury nid_oizo at yahoo.com_remove_the_
Fri Jun 3 15:26:54 EDT 2005


Guido van Rossum wrote:
> After many rounds of discussion on python-dev, I'm inviting public
> comments for PEP 343. Rather than posting the entire PEP text here,
> I'm inviting everyone to read it on line
> (http://www.python.org/peps/pep-0343.html) and then post comments on a
> Wiki page I've created for this purpose
> (http://wiki.python.org/moin/WithStatement).
> 
> I think this is a good one; I hope people agree. Its acceptance will
> obsolete about 4 other PEPs! (A sign that it fulfills a need and that
> the proposed solution is powerful.)

I like the PEP very much; I guess most C++ programmers are missing that 
capability in Python.  (I was following the discussion on python-dev, 
and I'm pleased and surprised how good the result/compromise is).

What about making the ':' optional (and end implicitly at end of current 
block) to avoid over-indentation?

def foo():
     with locking(someMutex)
     with opening(readFilename) as input
     with opening(writeFilename) as output
     ...

would be equivalent to:

def foo():
     with locking(someMutex)
         with opening(readFilename) as input
             with opening(writeFilename) as output
                 ...

Regards,

Nicolas



More information about the Python-list mailing list