Skip to main content

backport the magical zero-argument super() to python2

Project description

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…

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

autosuper-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file autosuper-0.1.0.tar.gz.

File metadata

  • Download URL: autosuper-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for autosuper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ee6417838983b46b24427dd29d341ee6df4222c045caecc6c3e1af7b4867409f
MD5 7ebdffbfef2a975d44e28b75c556afb7
BLAKE2b-256 ef43c87af38c44854b2f1fa2f8f7ce53b1a686fd01ebd386ffb98a9c0a63d4d6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page