TypeError when subclassing 'list'

Steve Juranich sjuranic at gmail.com
Sun Feb 26 17:30:11 EST 2006


Gerard Flanagan wrote:

> Hello all
> 
> Could anyone shed any light on the following Exception? The code which
> caused it is below.  Uncommenting the 'super' call in 'XmlNode' gives
> the same error. If I make XmlNode a subclass of 'object' rather than
> 'list' then the code will run.
...
> Code:
> 
> from elementtree.SimpleXMLWriter import XMLWriter
> 
> class XmlNode(list):
>     tag = None
>     attrib = None
>     value = None
>     def __init__(self, tag, **attrib):
>         #super(list, self).__init__()
>         self.tag = tag
>         self.attrib = attrib

I haven't put a lot of study into what you've done, but right off the bat,
your use of "super" is incorrect.  It should look like:

  super(XmlNode, self).__init__()

Not sure if that will fix your problem, though.

-- 
Steve Juranich
Tucson, AZ
USA




More information about the Python-list mailing list