Updated blog post on how to use super()
Duncan Booth
duncan.booth at invalid.invalid
Thu Jun 2 16:58:27 EDT 2011
Billy Mays <noway at nohow.com> wrote:
> I read this when it was on HN the other day, but I still don't see what
> is special about super(). It seems (from your post) to just be a stand
> in for the super class name? Is there something special I missed?
>
Consider any diamond hierarchy:
class Base(object): pass
class A(Base): pass
class B(Base): pass
class C(A, B): pass
If you have an instance of C, then in a method in A super() could refer to
a method in B which is not a base class of A.
If you have an instance of A then the sampe super() reference in one of A's
methods refers to the method in Base.
--
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list
mailing list