Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63071 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2014-01-04 03:07 +1100 |
| Last post | 2014-01-04 03:07 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Creating a list with holes Chris Angelico <rosuav@gmail.com> - 2014-01-04 03:07 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-01-04 03:07 +1100 |
| Subject | Re: Creating a list with holes |
| Message-ID | <mailman.4860.1388765238.18130.python-list@python.org> |
On Sat, Jan 4, 2014 at 2:55 AM, Larry Martell <larry.martell@gmail.com> wrote: > The use case is that I'm parsing a XML file like this: > > <Parameter Name="DefaultVersion"> > <Values> > <Value> > <Default>True</Default> > </Value> > </Values> > <Values> > <Value> > <Current>False</Current> > </Value> > </Values> > <Values> > <Value> > <Default>True</Default> > <Current>False</Current> > </Value> > </Values> > <Values> > <Default>True</Default> > </Values> > > This is an existing program that is putting the data into a dict. The > dict keys are ['DefaultVersion','Default'] and > ['DefaultVersion','Current']. These contain lists that have the > True/False values. Are you assigning keys by value, or are you simply appending to the lists? It looks to me like you could simply append another element to both lists for each <Value> </Value> unit, with the given Default and Current if available, or with None for any that aren't set. Alternatively, when you get up to the <Value>, append None to each list, and then when you see a value, assign to [-1] and overwrite the None. ChrisA
Back to top | Article view | comp.lang.python
csiph-web