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

Joao S. O. Bueno jsbueno at python.org.br
Fri Mar 4 14:15:41 CET 2011

On Fri, Mar 4, 2011 at 2:24 AM, Raymond Hettinger
<raymond.hettinger at gmail.com> wrote:

> To change the name of the class, you still have to do a global substitution,
> hitting the definition, every invocation, and its appearance in docs.  IOW,
> the class name is not a piece of knowledge that can be abstracted away.
> Another software engineering principle, the "Rule of Three" suggests that
> the proposed abstraction doesn't meet the minimum threshold of usefulness.
> Your idea may be valid and useful in other contexts, but named tuples aren't
> a good motivating use case, IMO.

Besides named tuples, I'd like to point out that the lack of such a
mechanism had already
made its way in other Libraries as things that are hard to read, and
generally used without the fully understanding of what is happening.:
exactly the creation of fields for ORM style frameworks
like we do have already in Django and the App Engine.

So, named tuples are far frombeing the unique or, IMHO, the most
relevant use case for such a feature.

> Raymond
> P.S.  The current approach to assignments has the virtue that it is readable
> to people coming from other languages.  The decorator approach creates a
> piece of Python arcana that would only be decipherable to a smaller number
> of people.

I am not arguing necessarily for the decorator approach. But I think
iti is relevant to have a syntactic language feature that allows the
creation of general objects that are aware of their "primary" names.


More information about the Python-ideas mailing list