Dynamic use of property() fails

Hrvoje Niksic hniksic at xemacs.org
Tue Apr 15 03:24:26 EDT 2008


"Gabriel Genellina" <gagsl-py2 at yahoo.com.ar> writes:

> The "magic" happens when the descriptor is found in the *class*, not
> in the instance. I think it's detailed in Hettinger's document.

The document is wrong here:

    Alternatively, it is more common for a descriptor to be invoked
    automatically upon attribute access. For example, obj.d looks up d
    in the dictionary of obj. If d defines the method __get__, then
    d.__get__(obj) is invoked according to the precedence rules listed
    below.

This sounds plausible and might have led Andrew to believe that his
code should work.  It should instead say "in the dictionary of obj's
type" or something to that effect.  I asked Raymond about it some time
ago, and he agreed that it's an error, but he apparently didn't get
around to fixing it.

The actual code examples in the document are, of course, correct.



More information about the Python-list mailing list