On Sat, Jan 4, 2014 at 2:55 AM, Larry Martell <larry.mart...@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 -- https://mail.python.org/mailman/listinfo/python-list