0

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

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Gribouillis
0

Thanks!!

Why are things so easy after you know the answer!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.