Hacker News new | ask | show | jobs
by mclin 5509 days ago
Have to deal with enough languages as it is. Don't want to further add to my brain mess by learning Python 3 syntax just yet.
2 comments

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

super() was introduced in CPython 2.2, but it changed in Python3: 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.

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

I 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.

Python 2.x doesn't have parameterless super() so apparently most of the article's code doesn't work with old versions.
Well, you just change to the Python 2 super call form and it works fine. The substitution hardly requires a master programmer...
super(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.
Python 3 was introduced two and a half years ago. Its major syntactic changes, while frustrating if you're set in your ways, are hardly insurmountable.
This. Most of the time I run into an issue with a change I wasn't aware of, a quick search through the 3.X docs just points me in the right direction.
I think it's fine if you're doing python all day long, but I'm using Python, Java, PHP, Obj-C and Javascript each at least once a month on a variety of paid and personal projects. Like I said, I have enough trouble keeping those syntaxes straight.