Dave Angel wrote:
2) I believe super() is new to new-style classes. In any case the
documentation for it seem to assume new-style.
Yes, super() only works for new style classes.
>>> class Test:
... def method(self):
... super(Test, self).method()
...
>>> t = Test()
>>> t.method()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in method
TypeError: super() argument 1 must be type, not classobj
Likewise for property(). property is particularly tricky, because it
*appears* to work for old style classes:
>>> class Test:
... def __init__(self, value):
... self._x = value
... def getx(self):
... print "Getting x"
... return self._x
... def setx(self, value):
... print "Setting x"
... self._x = value
... x = property(getx, setx)
...
>>> t = Test(42)
>>> t.x
Getting x
42
but actually doesn't work correctly:
>>> t.x = 12
>>> t.x
12
--
Steven
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor