[Python-ideas] multiple intro statements [was: combine for/with statement]

ron3200 ron3200 at gmail.com
Wed Aug 3 18:21:00 CEST 2011

On Wed, 2011-08-03 at 11:44 -0400, Jim Jewett wrote:

> On Wed, Aug 3, 2011 at 4:11 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> > With a slight relaxation of the rules concerning statements
> > on a single line, one could write
> >
> >    for bar in foo: with context: if baz:
> >        # stuff
> >
> > Not that I'd really advocate that, but it might help to
> > shut up the people who keep requesting this sort of thing.
> hmm... I actually sort of like that ...
>     statement: statement: statement:
>         suite
> is equivalent to
>     statement:
>         statement:
>             statement:
>                 suite
> On its own, it is a pure win to say "This statement really only does
> one thing; it is the subordinate statement that has a suite".  That
> said, I'm wondering if the colon is used for enough other things that
> it would end up causing confusion in practice with slices or
> formatting or ...
> -jJ

I think this is in the category of ...  If it isn't broke, don't fix


This tries to do two distinct things.
     1. Put multiple statements on a single line.
     2. Have them apply to a common block of code.

The main issues are with how those statements interact with the block.
Some statements are only done once, while others are meant to be done on
each iteration.  So the order becomes something of importance, and it
also becomes something of a problem to parse mentally.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110803/83c5615f/attachment.html>

More information about the Python-ideas mailing list