Py3k-alike style super() for Py2.x
Project description
Intro
newsuper provides you Python3k-alike super() for Python2.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__()
Python3k’s super() saves your ass a bit:
super().__init__()
but this looks evil, and confusing for classmethods
Example
You can create an Object class subclassing NewSuper,
and make your topest-level class subclassing it.:
from newsuper import NewSuper class Object(NewSuper): pass class Foo(Object): def __init__(self): self.foo = 1 @classmethod def do_something(cls): return 'nothing' class Bar(Foo): def __init__(self): super().__init__(self) self.bar = 1 @classmethod def do_something(cls): return [super().do_something(), 'another thing'] if __name__ == '__main__': assert Bar().foo == Bar().bar == 1 assert Bar.do_something() == ['nothing', 'another thing']
property is supported too.
Install
Let’s try it now
Use pip:
pip install newsuper
or easy_install:
easy_install newsuper
also, there is windows installer.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
newsuper-0.1b.zip
(5.3 kB
view hashes)
Built Distribution
newsuper-0.1b.win32.exe
(201.3 kB
view hashes)