Skip to main content

Python 3.x super() in 2.x

Project description


newsuper provides you Python 3.x super() in 2.x


you must hate to write code like this:

super(Foo, self).__init__()

and you might have written (WRONG) code like this:

super(self.__class__, self).__init__()

Python 3.x’s super() saves your ass:




Simply make your topest-level class inherited from newsuper.Object

from newsuper import Object

class Foo(Object):
    def __init__(self): = 1

    def do_something_with_class(cls):
        return [cls, 'Foo']

    def do_something_static():
        return ['Foo']

class Bar(Foo):
    def __init__(self):
        super().__init__() = 1

    def do_something_static(cls):
        return super().do_something_static() + ['Bar']

class Baz(Bar):
    def __init__(self):
        self.baz = 1

    def do_something_with_class(cls):
        # Compatible with old super(Baz, cls)
        return super(Baz, cls).do_something_with_class() + ['Baz']

    def do_something_static():
        # Yes, you can even super a staticmethod!
        return super().do_something_static() + ['Baz']

if __name__ == '__main__':
    assert Baz().foo == Baz().bar == Baz().baz == 1
    assert Baz.do_something_with_class() == [Baz, 'Foo', 'Baz']
    assert Baz.do_something_static() == ['Foo', 'Bar', 'Baz']

property is supported too.


Try it now!

Use pip:

pip install newsuper

or easy_install:

easy_install newsuper

also, there is windows installer.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution (5.3 kB view hashes)

Uploaded source

Built Distribution

newsuper-0.3c.win32.exe (201.6 kB view hashes)

Uploaded any

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page