[XML-SIG] Re: Problems with elementtree and versions of python.
Tony McDonald
tony.mcdonald at ncl.ac.uk
Fri Aug 1 18:12:23 EDT 2003
On Thursday, July 31, 2003, at 00:01AM, Fredrik Lundh wrote:
> 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>
>
That's great Fredrik, it does the job nicely (and elementree is a very
nice piece of software by the way).
Thanks again
Tone.
--
Dr Tony McDonald, Assistant Director, FMSC, http://www.fmcc.org.uk/
The Medical School, University of Newcastle upon Tyne, 0191 245 4223
Project manager, FDTL-4 eportfolios project,
http://www.eportfolios.ac.uk/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1156 bytes
Desc: not available
Url : http://mail.python.org/pipermail/xml-sig/attachments/20030801/60f43292/attachment.bin
More information about the XML-SIG
mailing list