Setter Propertys' mro?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Sep 7 00:10:28 EDT 2008


On Sat, 06 Sep 2008 18:15:33 -0700, cipher wrote:

> Whats the mro (method resolution order) of a setter property (__set__ on
> a descriptor).
> i seem to be experiencing some weird issue with them. for example
> 
>>>> class test:


Unless you're using Python 3, there's your problem right there. In Python 
2.x, properties only work correctly for new style classes, not classic 
classes. Change the above line to:

class Test(object):  # by convention, classes start with Uppercase.

and all should work (or at least you'll discover new and exciting 
different problems with your code).


> however, if i specify the metaclass in the class definition it works
> just fine...
> 
> class test:
>  __metaclass__=type

which is more or less the same as inheriting from object, except uglier.



-- 
Steven



More information about the Python-list mailing list