Inconsistent behavior of descriptors

Denis S. Otkidach ods at strana.ru
Wed Oct 1 06:11:35 EDT 2003


On Tue, 30 Sep 2003, John Roth wrote:

JR> > I've noticed that the order of attribute lookup is
JR> inconsistent
JR> > when descriptor is used.  property instance takes
JR> precedence of
JR> > instance attributes:
[...]
JR> > But it doesn't when I use custom class of descriptor:
[...]
JR> I'm not entirely sure what you're describing, however, I
JR> notice that your descriptor object has a __get__ method,
JR> but no __set__ or __del__ methods. The lookup chain
JR> is quite different for descriptors with only __get__ methods
JR> than it is for descriptors for all three.
JR>
JR> In particular, it's intended that instance attributes should
JR> be ignored if there is a data descriptor (that is, a
JR> descriptor
JR> with both__get__ and __set__ methods.)

Is it documented somewhere?  What is the reason for such
inconsistent behavior?

-- 
Denis S. Otkidach
http://www.python.ru/      [ru]






More information about the Python-list mailing list