Porting 3.0 to 2.6 - from __future__ import super missing?

andrew cooke andrew at acooke.org
Sat Jan 24 09:20:43 EST 2009


On Jan 24, 10:39 am, Benjamin Peterson <benja... at python.org> wrote:
> andrew cooke <andrew <at> acooke.org> writes:
>
>
>
> > Hi,
>
> > I have some 3.0 code, which I would like to make work with 2.6.
> > However, there does not seem to be support for the new super() (no
> > args) via __future__.  Is that correct?  If so, what's the best way to
> > handle this?
>
> Just use the two argument super(): super(MyClass, instance) It's supported in
> both versions.

Thanks.  Any idea how to deal with ABCs?  It's sufficient to use a
simple class, but I want to expose an ABC in 3.0 as it will make it
easier for others to extend.

Unfortunately, "metaclass=" is a syntax error in 2.6 so the following
still fails:

from sys import version

if version.startswith('2.'):
    class Matcher():
        pass
else:
    class Matcher(metaclass=ABCMeta):
        pass

Andrew



More information about the Python-list mailing list