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

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Mar 3 23:40:21 CET 2011

Ethan Furman wrote:
> Greg Ewing wrote:
>> I think we should have assignment decorators.
>> @decorator
>> lhs = rhs
> That seems very verbose -- part of the issue for me is all the extra 
> typing involved in specifying the name twice, and I don't think this is 
> going to save many, if any, keystrokes.

I don't follow. It costs an @ and a newline, but it saves
one instance of the name, plus two quotes, a comma and
perhaps a space.

Anyway, the main issue for me in violating DRY isn't the
number of keystrokes. The main issues are:

* It's harder to read -- the repeated name is just noise
   that doesn't convey any useful information to the reader.

* It's harder to maintain -- if you change the name, you
   have to remember to change it in both places.


More information about the Python-ideas mailing list