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. Also, a data descriptor takes precedence over any instance attribute of the same name that might exist.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to