Python 2.2 properties
Mark McEahern
marklists at mceahern.com
Tue Jan 15 12:43:56 EST 2002
"Steven D. Arnold" <stevena at neosynapse.net> wrote:
> Am I misunderstanding how properties work? It seems that given the
> code below, i.a ought to equal 5 no matter what. What am I doing
> wrong?
Thomas Heller wrote:
> You must derive your class from object:
> class foo(object):
I ran into this same problem. It took me a while to figure out that I had
to derive from object.
The documentation here:
http://www.amk.ca/python/2.2/index.html#SECTION000340000000000000000
does not seem explicit enough on this point. I'm not sure how best to
explicitly state it, perhaps right after this sentence:
"property is a new built-in type that packages up three functions that get,
set, or delete an attribute, and a docstring."
add something like:
"Note, to use property, your class must derive from object."
There's probably a better way of stating this--or maybe it's just me and
this is obvious to everyone.
Cheers,
// mark
More information about the Python-list
mailing list