[Python-ideas] A user story concerning things knowing their own names

Guido van Rossum guido at python.org
Sun Mar 20 16:10:46 CET 2011


On Fri, Mar 18, 2011 at 7:15 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Actually I don't want to reuse values, that was someone
> else. For my use case it's fine to create a new descriptor
> for each use.

So, apologies if this has been brought up or rejected before, wouldn't
a class decorator work for you? That is totally capable of calling
x.__addtoclass__() (or whatever you want to call it -- it's now
between the decorator and overridable_property) for each class
attribute (really: for each value in the class __dict__) that has it,
and doesn't seem to have the problems with combining unrelated
metaclasses that you brought up: unrelated class decorators combine
just fine (especially ones like this that mutate the class but still
return the original class object).

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list