Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #110494

Re: I seem to be creating a dict that I cannot access the keys of

From dieter <dieter@handshake.de>
Newsgroups comp.lang.python
Subject Re: I seem to be creating a dict that I cannot access the keys of
Date 2016-06-25 09:50 +0200
Message-ID <mailman.110.1466841055.11516.python-list@python.org> (permalink)
References <8c9b5b13-c6cc-458d-9d31-56f7e5db10c4@googlegroups.com> <871t3llnao.fsf@handshake.de>

Show all headers | View raw


Sayth Renshaw <flebber.crue@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`".

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

I seem to be creating a dict that I cannot access the keys of Sayth Renshaw <flebber.crue@gmail.com> - 2016-06-23 20:59 -0700
  Re: I seem to be creating a dict that I cannot access the keys of dieter <dieter@handshake.de> - 2016-06-25 09:50 +0200
    Re: I seem to be creating a dict that I cannot access the keys of Sayth Renshaw <flebber.crue@gmail.com> - 2016-06-25 01:41 -0700
      Re: I seem to be creating a dict that I cannot access the keys of dieter <dieter@handshake.de> - 2016-06-27 09:08 +0200

csiph-web