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

Raymond Hettinger raymond.hettinger at gmail.com
Fri Mar 4 03:32:31 CET 2011


On Mar 3, 2011, at 6:20 PM, MRAB wrote:

> 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'
>> 
>> [snip]
>> 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)

FWIW, I'm not proposing either of those syntax changes.  Those were just examples.

The main point is that a new syntax change is a big deal, so it ought to be saved
for something that greatly expands our expressive power, adds substantive
improvements to existing programs, or is mind-expanding in some way.
The with-statement was a good example of something that met all of those criteria.

If you're going to change the language syntax, make it count and do something cool :-)


Raymond


More information about the Python-ideas mailing list