Kent Johnson wrote: > 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
Nope. This is by design; Elements are intended to be contained, not subclassed. (you cannot subclass ElementTree Elements either; Element is a factory function, not a class). To solve the navigation issue, you could either use a dictionary that keeps track of child-parent relations, or use a proxy wrapper. Or see if you can structure your code so you always work from parents (that's usually easier than you may think). </F> -- http://mail.python.org/mailman/listinfo/python-list