I am trying to Subclass ElementTree with an abstract method. I have read in several forums that ElementTree is actually both a module and a class. I have been unable to get the subclassing to work.
from abc import ABCMeta, abstractmethod
from xml.etree.ElementTree import ElementTree, Element, tostring
class A(ElementTree):
__metaclass__ = ABCMeta
def __init__(self):
pass
@abstractmethod
def update(self):
pass
The error is as follows:
Traceback (most recent call last):
File "A.py", line 4, in <module>
class A(ElementTree):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/abc.py", line 76, in __new__
cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
TypeError: Error when calling the metaclass bases
a new-style class can't have only classic bases