Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63092
| 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 | <larry.martell@gmail.com> |
| 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 | <CAPTjJmphBdTObUKQyk9nwSjN60zqUnHScYZ0OJA6Oym+2cDe_Q@mail.gmail.com> |
| References | <CACwCsY5P47-dB1NLQTUTQ=0aF6B+-M3y4hCxcUGmcVmHM8=-xQ@mail.gmail.com> <CAPTjJmp+NtGYWE3S3SGjo-xoYC74Exdpci_+x4AUNgqM5=CJNQ@mail.gmail.com> <CACwCsY6J0-v0EfKRj5XCCdL9ym6MxpGuXqu93DXLuhVOhuRVJw@mail.gmail.com> <CAPTjJmphBdTObUKQyk9nwSjN60zqUnHScYZ0OJA6Oym+2cDe_Q@mail.gmail.com> |
| Date | Fri, 3 Jan 2014 19:18:26 -0500 |
| Subject | Re: Creating a list with holes |
| From | Larry Martell <larry.martell@gmail.com> |
| To | "python-list@python.org" <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 <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4872.1388794708.18130.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
On Fri, Jan 3, 2014 at 11:07 AM, Chris Angelico <rosuav@gmail.com> wrote: > 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. Your last suggestion is what I ended up doing, but I had to key off the <Values> </Values> unit - I couldn't use <Value> because that isn't present for ones that have no <Current> - that messed me up for hours. But it's working now. Thanks all!
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Creating a list with holes Larry Martell <larry.martell@gmail.com> - 2014-01-03 19:18 -0500
csiph-web