[Python-ideas] Long Live PEP 3150 (was: Re: Statement local functions and classes (aka PEP 3150 is dead, say 'Hi!' to PEP 403))

Eric Snow ericsnowcurrently at gmail.com
Sun Oct 16 07:20:12 CEST 2011


On Fri, Oct 14, 2011 at 12:28 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> I know for a fact that Nick knows a lot more than me (and has been at
> this a lot longer), so I assume that I'm missing something here.  The
> big advantage of the post-order given statement, that I see, is that
> you can do a one-liner:
>
>   x = [given.len(i) for i in somebiglist] given: len = len
>
> vs.
>
>   given: len = len
>   x = [given.len(i) for i in somebiglist]

After Nick's update to PEP 3150 I saw the post-order light (sort of).
If you restrict the given clause to just simple statements, as the PEP
does, the post-order variant actually makes more sense.  The given
clause for simple statements is like giving a suite to all the
statements that don't have one[1].  The original statement is then the
header for the subsequent block.  I like that.

If the new syntax were exclusive to simple statements then that's a
good fit.  I still prefer the in-order variant for compound statements
though (they already have their own suite).  If PEP 3150 were to march
ahead with post-order, we probably couldn't add in-order given clauses
for compound statements later, could we?  Does it matter?

-eric

[1] http://mail.python.org/pipermail/python-ideas/2011-April/009891.html



More information about the Python-ideas mailing list