3 ms·
super() was introduced in Python2.2 many years ago. Everything in the article works with very old versions of Python. Here's a link to the Python 2 version of
by raymondh 15y ago
super() was introduced in Python2.2 many years ago. Everything in the article works with very old versions of Python.
Here's a link to the Python 2 version of the examples: http://code.activestate.com/recipes/577721-how-to-use-super-effectively-python-27-version/ http://code.activestate.com/recipes/577721-how-to-use-super-...
- kunley 15y agoPython 2.x doesn't have parameterless super() so apparently most of the article's code doesn't work with old versions.
- fuzzyman 15y agoWell, you just change to the Python 2 super call form and it works fine. The substitution hardly requires a master programmer...
- bendotc 15y agosuper() was introduced in CPython 2.2, but it changed in Python3: http://www.python.org/dev/peps/pep-3135/ http://www.python.org/dev/peps/pep-3135/. The link you posted uses super as "super(cls, instance)", but the main article uses Python 3's super, which can just be called as "super()", and it figures out the class and instance. So no, super really has changed, and the syntax in the article does not work with very old version of Python.
- bretthoerner 15y ago> So no, super really has changed, and the syntax in the article does not work with very old version of Python. Oh come on, he's saying if you do the incredibly minor syntax adjustment that all of the actual meat of the article still works in Python 2.
- nicpottier 15y agoI upvoted the parent, because that syntax distinction is actually fairly giant, always having to name the class and also changing that on renames etc, is a PITA. It is actually one of the things that annoys me most about Python, I guess this is the first thing that actually tempts me with Python 3. Damn.
- mclin 15y agosuper(myclass, self) was. Like I posted below, sometimes I have real trouble keeping the 5 or so languages I use straight. The other day I actually forgot what 'None' is in python because I hadn't used it in a few days, and None is different than in the others.