[XML-SIG] Re: Problems with elementtree and versions of python.

Fredrik Lundh fredrik at pythonware.com
Thu Jul 31 02:01:57 EDT 2003


Tony McDonald wrote:

> I'm having real problems with it though - and I think it's a python version
> thing.
>
> Eg using the code from
> http://online.effbot.org/2003_07_01_archive.htm#element-tricks-2

it took me a while to figure it out, but it's a bug in the ElementWrapper
sample, not in the ElementTree library.

changing the ElementWrapper __getattr__ code from

    def __getattr__(self, tag):
        return self._element.findtext(self._ns + tag)

to

    def __getattr__(self, tag):
        if tag.startswith("__"):
            raise AttributeError(tag)
        return self._element.findtext(self._ns + tag)

should help.

</F>






More information about the XML-SIG mailing list