Search code examples
pythonpython-3.xsuperpython-2.5

Can I use Python 3 super() in Python 2.5.6?


Can I use clean Python 3 super() syntax in Python 2.5.6?
Maybe with some kind of __future__ import?


Solution

  • You cannot use a bare super() call that contains no type/class. Nor can you implement a replacement for it that will work. Python 3.x contains special support to enable bare super() calls (it places a __class__ cell variable in all functions defined within a class - see PEP 3135


    Update

    As of Python 2.6+, bare super() calls can be used via the future Python package. See posita's answer for an explanation.