On Thu, 23 Jul 2009 01:05:55 +0100, Gabriel Genellina <gagsl-...@yahoo.com.ar> wrote:

En Wed, 22 Jul 2009 11:01:09 -0300, Rhodri James <rho...@wildebst.demon.co.uk> escribió:
On Wed, 22 Jul 2009 06:02:55 +0100, Gabriel Genellina <gagsl-...@yahoo.com.ar> wrote:


class X(object):
   foo = descriptor()

x = X()
x.foo = "value"

Isn't this going to create a brand new instance attribute x.foo that has nothing to do with the descriptor anyway?

No, it's up to the descriptor __set__ method what happens in this case. Think of the standard 'property' descriptor, the fset function can do whatever it wants.

If it gets called, that is.

Also, a data descriptor takes precedence over any instance attribute of the same name that might exist.

This was the bit I wasn't clear on.  Thanks!

--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to