This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients rhettinger
Date 2012-09-25.23:20:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1348615231.16.0.514985949274.issue16049@psf.upfronthosting.co.za>
In-reply-to
Content
Since inheritance is more commonplace and more easily understood than __metaclass__, the abc module would benefit from a simple helper class:

    class ABC(metaclass=ABCMeta):
        pass

From a user's point-of-view, writing an abstract base call becomes simpler and clearer:

    from abc import ABC, abstractmethod

    class Vector(ABC):

        @abstractmethod
        def __iter__(self):
            pass

        def dot(self, other):
            'Compute a dot product'
            return sum(map(operator.mul, self, other))

Notice that this class seems less mysterious because it inherits from ABC rather than using __metaclass__=ABCMeta.

Also note, it has become a reasonably common practice for metaclass writers to put the __metaclass__ assignment in a class and have it get inherited rather than requiring users do the metaclass assignment themselves.
History
Date User Action Args
2012-09-25 23:20:31rhettingersetrecipients: + rhettinger
2012-09-25 23:20:31rhettingersetmessageid: <1348615231.16.0.514985949274.issue16049@psf.upfronthosting.co.za>
2012-09-25 23:20:10rhettingerlinkissue16049 messages
2012-09-25 23:20:09rhettingercreate