[Python-ideas] Before and after the colon in funciton defs.

Chris Rebert pyideas at rebertia.com
Thu Sep 22 04:46:59 CEST 2011


On Wed, Sep 21, 2011 at 7:31 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> On Wed, Sep 21, 2011 at 7:01 PM, Jan Kaliszewski <zuo at chopin.edu.pl> wrote:
>> I'm adding both new propositions:
>>
>> 1. the `def foo(...) [len=len]:` syntax,
>> 2. the `len = (static len)` expression syntax
>>
>> -- to the PEP-draft I'm preparing -- which Nick suggested in June
<snip>
>> Ad 2: I must admit that this one becomes my favorite syntax for
>> early binding (though I don't like the abbreviated form '(i=i)').
>>
>> IMHO it's not only clear (no all that questions about assignment
>> semantics) but also elegant, explicit and consistent with some existing
>> syntax constructs (especially with `yield EXPR`).
>>
>> Note that (as you can use any expression) it makes possible to use e.g.
>> tuples of several names:
>>
>>    spam, print, open = static (len, print, open)
>>
>> Big +1 from me.
>
> Agreed, though the the keyword should be on the LHS:
>
>  static spam, print, open = len, print, open
>
> It's more consistent with other keywords that way and easier to spot
> when reading code.

+1 (FWIW) on this "assignment statement with leading keyword" variant.
`static` is an excellent choice of keyword for this.

Cheers,
Chris



More information about the Python-ideas mailing list