Python 3K or Python 2.9?
Delaney, Timothy (Tim)
tdelaney at avaya.com
Mon Sep 17 04:30:00 EDT 2007
Ben Finney wrote:
> The latter two statements are equivalent. The 'instance.method(args)'
> syntax is just sugar for 'Class.method(instance, args)'.
Only in the case that "instance" is an instance of "Class", and not an
instance of a subclass of "Class". For example, the following are not
equivalent:
class A(object):
def func(self):
print 'A'
class B(A):
def func(self):
super(B, self).func()
print 'B'
a = A()
b = B()
A.func(a)
A.func(b)
B.func(b)
a.func()
b.func()
Tim Delaney
More information about the Python-list
mailing list