November 30, 2008

python: super() method and new style class

if you want to use super() method to reuse a method in the parent class, you have to make sure the parent class is a “new style class”. simply speaking, any new style class can trace their inheritance to the bulit-in class “object”. For example, if you want to do

class C(B):
  def meth(self, arg):
    super(C, self).meth(arg)

Make sure B is defined as

class B(object):

or

class B(int):

etc...

Comments »

The URI to TrackBack this entry is: http://songwei.blogsome.com/2008/11/30/python-super-method-and-new-style-class/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>