property problem

Thomas Heller theller at python.net
Thu Jul 18 10:57:57 EDT 2002


Your class proptest must derive from 'object':

class proptest(object):
...

Quoting from http://www.python.org/2.2.1/descrintro.html#property:

"""Properties do not work for classic classes, but you don't get a
clear error when you try this. Your get method will be called,
so it appears to work, but upon attribute assignment, a classic
class instance will simply set the value in its __dict__ without
calling the property's set method, and after that, the property's
get method won't be called either. (You could override __setattr__
to fix this, but it would be prohibitively expensive.)
"""

Thomas





More information about the Python-list mailing list