[Python-ideas] Assignment decorators (Re: The Descriptor Protocol...)
ethan at stoneleaf.us
Fri Mar 4 00:13:37 CET 2011
Greg Ewing wrote:
> Ethan Furman wrote:
>> Greg Ewing wrote:
>>> I think we should have assignment decorators.
>>> 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.
Ah -- I thought 'decorator' was a stand-in for an actual decorator name.
Still not in love with it though... an @ on a line all by itself?
Ick. (How's that for a reasoned argument? ;)
> 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.
Yup, those are the main issues. Didn't someone say that meta-classes
can be used to solve this issue?
More information about the Python-ideas