Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Intro

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

Why

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:

super().__init__()

YOU WANT IT IN 2.X!

Example

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

from newsuper import Object

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

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

    @staticmethod
    def do_something_static():
        return ['Foo']

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

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

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

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

    @staticmethod
    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.

Install

Try it now!

Use pip:

pip install newsuper

or easy_install:

easy_install newsuper

also, there is windows installer.

Metadata

Release files for newsuper 0.3c

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for newsuper 0.3c
File Size Uploaded
newsuper-0.3c.zip 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for newsuper 0.3c
File Interpreter ABI Platform
newsuper-0.3c.win32.exe Details

Total release size: 206.9 kB

Release files / newsuper-0.3c.zip

Download URL newsuper-0.3c.zip
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6f57979d191a52b64c9c50ab608959c010e7b6539c4bcf31b9393ad3d1daf6da
BLAKE2b-256 checksum
How to use checksums
dd610fd19538b105a40fe6c55739958f286fbfb778d54134cea44892d0fb00c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / newsuper-0.3c.win32.exe

Download URL newsuper-0.3c.win32.exe
Size 201.6 kB
Tags Source
SHA-256 checksum
How to use checksums
47767103c262abcf7a5e64a5aed44eec3eebd0cf195aff2d474a9124c6bdc0d1
BLAKE2b-256 checksum
How to use checksums
ce4329a5d6ef9716d7e27d750a940ff8a19c75c2fa1a54bb77458d058056bb13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page