Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.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.003 X-Spam-Evidence: '*H*': 0.99; '*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; 'jan': 0.12; 'dict': 0.16; 'doing,': 0.16; 'none.': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'putting': 0.22; 'to:name:python-list@python.org': 0.22; "aren't": 0.24; 'looks': 0.24; 'this:': 0.26; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; '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; 'fri,': 0.33; 'could': 0.34; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'set.': 0.36; 'thanks': 0.36; 'unit': 0.37; 'to:addr:python-list': 0.38; 'list,': 0.38; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'simply': 0.61; 'default': 0.69; 'all!': 0.84; 'dict.': 0.84; 'messed': 0.84 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:to :content-type; bh=58JYZrLgjw5cMhawKvm6MlsTjpdraYsPtqjEL3Sfw3o=; b=qv3Mf55b07YC2IvjKXgMywpNsza71ViLgGqceWTNlWcszhyuFXMV6K92bLZrbxZSto v/qjroPsjLck9cjLZ5nCMhhZpm6Fb5diBaMYQD1eMMKdmttSlgSIeh88bpFUvXIIkGVV 98ZGKHZhCAXZMu8oVipw1l5wdlzvWfTNDf8PPYzxhCAOKSCiq6+wUybOD2wR3C4whYLT SKvYg/CspMBhWWeBbZplQCsZQRyztlByZjI2P6sMvig3SRMasuwSUV5HD8cpF7KLgi1/ OPTz+7Ty7qkjrwS+lpLV7EYN1sTPB3qyknw+JtuL+QD/GOyWMvwTCimDqZA+6Cv9R6sX PvrA== MIME-Version: 1.0 X-Received: by 10.180.215.3 with SMTP id oe3mr3728931wic.35.1388794706682; Fri, 03 Jan 2014 16:18:26 -0800 (PST) In-Reply-To: References: Date: Fri, 3 Jan 2014 19:18:26 -0500 Subject: Re: Creating a list with holes From: Larry Martell To: "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: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1388794708 news.xs4all.nl 2940 [2001:888:2000:d::a6]:33975 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63092 On Fri, Jan 3, 2014 at 11:07 AM, Chris Angelico wrote: > 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. Your last suggestion is what I ended up doing, but I had to key off the unit - I couldn't use because that isn't present for ones that have no - that messed me up for hours. But it's working now. Thanks all!