Skip to main content

autosuper: backport the magical zero-argument super() to python2

This is an (awful, hacky, wtf-were-you-thinking) attempt to port the magical zero-argument super() call from python3 to python2.

In standard python2 usage of the super() builtin, you have to repeat both the class and instance objects when you call super, like this:

class Hello(Base):
def hello(self):

super(Hello,self).hello()

Using autosuper, you can get the friendlier behaviour from python3 where it just figures out the correct call at runtime:

class Hello(Base):
def hello(self):

super().hello()

Of course, you can still explicitly pass in the arguments if you want to do something strange. Sometimes you really do want that, e.g. to skip over some classes in the method resolution order.

How does it work? By inspecting the calling frame to determine the function object being executed and the object on which it’s being called, and then walking the object’s __mro__ chain to find out where that function was defined. Yuck, but it seems to work…

Metadata

Release files for autosuper 0.1.0

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

Source distribution (sdist)

Source distribution for autosuper 0.1.0
File Size Uploaded Provenance Actions
autosuper-0.1.0.tar.gz 3.5 kB Without provenance Details for autosuper-0.1.0.tar.gz

Release files / autosuper-0.1.0.tar.gz

Download URL autosuper-0.1.0.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ee6417838983b46b24427dd29d341ee6df4222c045caecc6c3e1af7b4867409f
BLAKE2b-256 checksum
How to use checksums
ef43c87af38c44854b2f1fa2f8f7ce53b1a686fd01ebd386ffb98a9c0a63d4d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for autosuper 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

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