[Python-Dev] PEP 310 Status

Phillip J. Eby pje at telecommunity.com
Tue Nov 16 17:27:58 CET 2004


At 11:01 AM 11/16/04 -0500, Michael Walter wrote:
>Hello everyone,
>
>I was just wondering about the status of PEP 310 ("with" statement) -
>has there been any concensus/plan to implement it? (I tried to google
>the answer, but failed ;-)

Guido has previously said that "with" is reserved for a use similar to the 
use of the "with" statement in Turbo Pascal and Visual Basic; that is, a 
shortcut for referring to a long expression.  Whether that means PEP 310 
needs a new keyword, or that it needs to play a dual role, I'm not sure.


>How about the potentiel inclusion of user-defined "blocks"? I suppose
>this would be only a Python 3000 thing, if ever included?

With the advent of PEP 318, it's now possible to do block-like things with 
closures and decorators, e.g.:

     @with_lock(mylock)
     def do_something():
         # code here

     do_something()

This is somewhat ugly, however, when used in-line.  On the other hand, this 
could also be viewed as an encouragement to modularize more, in order to 
have more readable code.  :)



More information about the Python-Dev mailing list