Using abc.ABCMeta in a way it is compatible both with Python 2.7 and Python 3.5

You could use six.add_metaclass or six.with_metaclass:

import abc, six

@six.add_metaclass(abc.ABCMeta)
class SomeAbstractClass():
    @abc.abstractmethod
    def do_something(self):
        pass

six is a Python 2 and 3 compatibility library. You can install it by running pip install six or by downloading the latest version of six.py to your project directory.

For those of you who prefer future over six, the relevant function is future.utils.with_metaclass.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)