object oriented inheritance problem

Matthew Thorley ruach at chpc.utah.edu
Tue May 10 12:40:35 EDT 2005


I am trying to inherit from ElementTree so I can add some methods. This
is the code I am trying to make work, and the following is the error I
am getting.

from elementtree import ElementTree
class AcidTree(ElementTree):
    def write_string(self):
        ....

File "/home/hope/var/proj/acid/server/mgacparse.py", line 22, in ?
    class AcidTree(ElementTree):
TypeError: Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)


I have *no* idea what is going on here. AcidTree does not implement an
__init__. It just adds two simple methods, which aren't even being
called when then exception is thrown. The exception occurs on the class
definition line when I try to inherit from ElementTree.

I looked around, and read some stuff in the python cook book, and
everything I've seen indicates that it should just work. My only thought
is that its a 'oldstyle' vs 'newstyle' classes issue. I know that
elementtree was written to be compatible with python 1.5 so maybe it
doesn't work with the new stuff. But thats just a crazy assumption I
made up to make myself feel better.

If anyone could please exmplain what my problem *really* is I would
appreciate it greatly. Thanks very much.

-Matthew



More information about the Python-list mailing list