Python extending with - using super() Python 3 vs Python 2

The Solution to Python extending with - using super() Python 3 vs Python 2 is


  • super() (without arguments) was introduced in Python 3 (along with __class__):

    super() -> same as super(__class__, self)
    

    so that would be the Python 2 equivalent for new-style classes:

    super(CurrentClass, self)
    
  • for old-style classes you can always use:

     class Classname(OldStyleParent):
        def __init__(self, *args, **kwargs):
            OldStyleParent.__init__(self, *args, **kwargs)
    

~ Answered on 2012-05-07 13:44:13


Most Viewed Questions: