[Python-ideas] Assignment decorators (Re: The Descriptor Protocol...)

Nick Coghlan ncoghlan at gmail.com
Thu Mar 10 13:49:41 CET 2011


On Thu, Mar 10, 2011 at 6:20 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 10 March 2011 01:37, MRAB <python at mrabarnett.plus.com> wrote:
>>> I don't like the suggestion as written, but I quite like it as a
>>> superior syntax proposal for PEP 359.
>>>
>>> def (builder) name(param_spec):
>>>     code_block
>>>
>> I think what I don't like is that the name is buried in the middle of
>> the line and not near the start as in the "class" or "def" statement.
>
> Syntactically, I have the same concern - when I first read that line I
> didn't spot "name" at all.

I actually agree it is a major weakness of the syntax. You can play
games with "from" to rearrange the line. For example:

def name from builder(param_spec):
  code_block

as sugar for:

name = builder("name", param_spec_obj, code_obj)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list