[Python-Dev] PEP 310 Status

Michael Walter michael.walter at gmail.com
Tue Nov 16 17:35:57 CET 2004


This doesn't quite work for different use cases of blocks, such as
generating markup using something like "with <tag>: <suite>".

Of course one (could|should|will) argue that this is an attempt to
extend Python's syntax, basically "abusing" with beyond its original
scope. I don't know whether this is a bad thing.

Cheers,
Michael


On Tue, 16 Nov 2004 11:27:58 -0500, Phillip J. Eby
<pje at telecommunity.com> wrote:
> 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