[Python-Dev] PEP 343 - next steps

Barry Warsaw barry at python.org
Sat Jun 11 23:43:43 CEST 2005


On Fri, 2005-06-10 at 16:23, Guido van Rossum wrote:
> While there's still some activity in the Wiki, nothing (to me) sounds
> like signs of serious disagreement or truly better alternatives. So I
> think I'd like to move forward towards acceptance soon (before
> EuroPython).

Well, I finally read PEP 343 in its entirety.  Having not really had the
time to follow this thread, I have to say "well done".  I like the PEP a
lot and can see many places in my own code where it would make things
more readable.

I have one comment, and I may be too late or may be repeating other
suggestions (no, I haven't poured through the wiki page yet).  I
actually don't think "with" reads as well and would propose "when".  The
word I'd really like to use here is "while" but given that we already
have while loops and "as" is optional, I don't think that's a
possibility.  If you made "as" required, it would be though, I think.

Look at the given examples:

with locking(mylock):
when locking(mylock):

with opening("/etc/passwd") as f:
when opening("/etc/passwd") as f:

with opening(filename, "w") as f:
    with redirecting_stdout(f):
        print "Hello world"

when opening(filename, "w") as f:
    when redirecting_stdout(f):
        print "Hello world"

with signal_blocking():
when signal_blocking():

> - throw() is a term taken from Java & C++. We can't call the method
> raise() -- but perhaps we can call it next_raising() or next_raise(),
> which emphasizes the similarity with next(). Thoughts? I'm not strong
> on this; I think throw() is fine too, especially since I expect that
> it will be used explicitly extremely rarely -- the only customer is
> the with_template decorator.

As others have mentioned "throw()" is fine.

> - Whether and how to keep a door open for a future extension to the
> syntax that allows multiple resources to be acquired in a single
> with-statement. Possible syntax could be
> 
> (a)    with EXPR1 [as VAR1], EXPR2 [as VAR2], EXPR3 [as VAR3], ...:
> 
> or
> 
> (b)    with EXPR1, EXPR2, EXPR3, ... as VAR1, VAR2, VAR3, ...:

I agree that (a) is better and feel +1 on keeping the door open to it.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20050611/235c0e15/attachment-0001.pgp


More information about the Python-Dev mailing list