I seem to be creating a dict that I cannot access the keys of
dieter
dieter at handshake.de
Sat Jun 25 03:50:39 EDT 2016
Sayth Renshaw <flebber.crue at gmail.com> writes:
> ...
> Can I ask is there something obvious wrong, i have left the commented other versions in they "work" in that they all produce the same output the print whole file.
>
The code below is obviously wrong - it is surprising that you get
anything other than an exception. See comments below inserted into
your code.
> def parseXML():
> ...
> result = etree.tostring(tree.getroot(), pretty_print=True)
"result" here is obviously a string.
> for sample in result:
This means that "sample" successively hold the characters composing
the string "result".
> noms = (dict(zip(atts, map(sample.attrib.get, atts))))
You should get "AttributeError: str object does not have attribute `attrib`".
More information about the Python-list
mailing list