Why do calls of super() methods behave different for __init__ and standard methods?

Andrew Bennetts andrew-pythonlist at puzzling.org
Wed May 14 05:07:45 EDT 2003


On Wed, May 14, 2003 at 10:53:58AM +0200, Mirko Zeibig wrote:
> Hello,
> 
> I have the following snippet:
> --- snip ---
> #!/usr/bin/python
> 
> class A(object):
>     def __init__(self):
>         super(A, self).__init__()
>         print "Ctr A"
> 
>     def display(self):
>         print "A: %s" % self

A.display doesn't call super, but A.__init__ does.

> class B(object):
> 
>     def __init__(self):
>         super(B, self).__init__()
>         print "Ctr B"
> 
>     def display(self):
>         print "B: %s" % self

Ditto B.display vs. B.__init__.

-Andrew.






More information about the Python-list mailing list