Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'skip:[ 20': 0.04; 'value,': 0.04; 'assign': 0.07; 'element': 0.07; 'append': 0.09; 'assigning': 0.09; 'overwrite': 0.09; 'parsing': 0.09; 'cc:addr :python-list': 0.11; 'jan': 0.12; 'dict': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'none.': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'putting': 0.22; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'xml': 0.29; 'subject:list': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'keys': 0.31; 'larry': 0.31; 'lists?': 0.31; 'values.': 0.31; 'file': 0.32; 'lists': 0.32; 'another': 0.32; 'could': 0.34; 'subject:with': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'set.': 0.36; 'list,': 0.38; 'simply': 0.61; 'default': 0.69; 'dict.': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=MlW+H7L0toovEB6q952WkmsPioE+m/uEPpWnQtl5mVQ=; b=geIm/myBhJEiA19SssmZvDRmnqJE8kon0kmTuvL65NPALuPxxvA/+b033p4iLDMmub CDsxSs5BG6GjuSNsvBrOJXwA+sG8maEpK+QUer6lM5I68d3rYGPChgKoCCg4oBRAScdv dLviHuOTzSbhCCUmKcfWGoibRXf3+dx47qQbawD4WjVYqSJZ5sAl5WxqqEJWiyA8f9cn /00Ifm/4Viv6gsjLBPfJalKcKWjB6MGagOOUf1Q6Ek75QCiPWozU8PZD9c7K7RXY+gZI KWyUcnbATNJC0t1s+hfLWhpiCx9H4YmLblFgM0fwyrDiulvbv+PGDBP5I1X2eIHAj47x cg4w== MIME-Version: 1.0 X-Received: by 10.68.98.3 with SMTP id ee3mr11245167pbb.31.1388765228814; Fri, 03 Jan 2014 08:07:08 -0800 (PST) In-Reply-To: References: Date: Sat, 4 Jan 2014 03:07:08 +1100 Subject: Re: Creating a list with holes From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1388765238 news.xs4all.nl 2866 [2001:888:2000:d::a6]:55737 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63071 On Sat, Jan 4, 2014 at 2:55 AM, Larry Martell wrote: > The use case is that I'm parsing a XML file like this: > > > > > True > > > > > False > > > > > True > False > > > > True > > > 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 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 , append None to each list, and then when you see a value, assign to [-1] and overwrite the None. ChrisA