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

MRAB python at mrabarnett.plus.com
Fri Mar 4 03:20:39 CET 2011


On 04/03/2011 01:59, Raymond Hettinger wrote:
>
> On Mar 3, 2011, at 4:19 PM, Greg Ewing wrote:
>> . For example, currently you write
>>
>>  Fred = namedtuple('Fred', 'x y z')
>>
>> This would become
>>
>>  @namedtuple
>>  Fred = 'x y z'
>
> How are tuples handled?
>
>    @deco
>     C = a, b, c
>
> Is this C('C', a, b, c) or C('C', (a, b, c))?
>
> All in all this seems like too much firepower (a language syntax 
> change) for too little benefit (how much do we really care that 'C' 
> got typed twice?).
>
> If there were going to be only one syntax change for Python 3.3, why 
> not use it for something that adds a lot more expressive power:
>
>     x = a!name      #  x = getattr(a, name)
>
[snip]

Or:
     x = a.(name)



More information about the Python-ideas mailing list