Subclassing cElementTree.Element

Kent Johnson kent37 at tds.net
Mon Feb 7 18:33:37 EST 2005


Is it possible to subclass cElementTree.Element? I tried
  >>> import cElementTree as et
  >>> class Elt(et.Element):
  ...   pass
  ...
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
TypeError: Error when calling the metaclass bases
     cannot create 'builtin_function_or_method' instances

I want to create a tree where I can navigate from a node to its parent. The standard Element class
doesn't seem to support this so I am trying to make a subclass that does. The XML files in question
are large so the speed of cElementTree is very helpful.

Thanks,
Kent

(apologies if this is a duplicate post)



More information about the Python-list mailing list