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

Guido van Rossum guido at python.org
Thu Mar 10 20:02:23 CET 2011

On Thu, Mar 10, 2011 at 11:41 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 10 March 2011 12:49, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> 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)
> Yes, I like that better...

I'd like it better if it came with a default builder implementation
that would create regular functions, so that

def name(<params>):

was equivalent to

def name from <defaultbuilder>(<params>):

But I don't see a reasonable way to do that.

Also I think it's confusing to have both

def name(<params>): ...


def name from some_magic(<params): ...

with different semantics.

--Guido van Rossum (python.org/~guido)

More information about the Python-ideas mailing list