where is the Write method of ElementTree??

Stefan Behnel stefan_ml at behnel.de
Fri May 23 03:22:06 EDT 2008


gray.bowman at gmail.com wrote:
> I'm messing around with trying to write an xml file using
> xml.etree.ElementTree.  All the examples on the internet show the use
> of ElementTree.write(), although when I try to use it it's not
> available, gives me ...
> 
>    ElementTree(sectionElement).write("section.xml")
> TypeError: 'module' object is not callable

I guess you did

    from xml.etree import ElementTree

Then you should do this:

    ElementTree.ElementTree(sectionElement).write("section.xml")

sadly, the module names in ET are upper case and look like classes...

Stefan



More information about the Python-list mailing list