Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19966

Re: iterating over list with one mising value

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.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; 'value,': 0.04; 'am,': 0.12; 'exception': 0.12; 'structures': 0.15; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'message- id:@tim.thechases.com': 0.16; 'pad': 0.16; 'received:50': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'cc:no real name:2**0': 0.21; 'subject:list': 0.21; 'header:In-Reply- To:1': 0.22; '(or': 0.22; 'feb': 0.22; 'ignore': 0.24; 'cc:2**0': 0.26; 'asking': 0.28; 'value.': 0.28; "i'm": 0.28; 'example': 0.29; 'cc:addr:python.org': 0.29; 'tuples': 0.30; 'source': 0.32; 'list': 0.32; 'header:User-Agent:1': 0.33; 'routine': 0.34; 'trouble': 0.35; 'list.': 0.35; 'question': 0.36; 'using': 0.37; 'subject:with': 0.37; 'data': 0.38; 'johnson': 0.39; 'more': 0.61; 'here': 0.64; 'subject:one': 0.77; 'subject:over': 0.84; 'subject:value': 0.84
Date Tue, 07 Feb 2012 10:34:32 -0600
From Tim Chase <python.list@tim.thechases.com>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16
MIME-Version 1.0
To Rick Johnson <rantingrickjohnson@gmail.com>
Subject Re: iterating over list with one mising value
References <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> <mailman.5502.1328625983.27778.python-list@python.org> <fcc877f5-2ae2-4cd5-9e73-727f4b3173d7@f30g2000yqh.googlegroups.com>
In-Reply-To <fcc877f5-2ae2-4cd5-9e73-727f4b3173d7@f30g2000yqh.googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
X-Source
X-Source-Args
X-Source-Dir
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5504.1328632452.27778.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1328632452 news.xs4all.nl 6935 [2001:888:2000:d::a6]:39491
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19966

Show key headers only | View raw


On 02/07/12 09:34, Rick Johnson wrote:
> On Feb 7, 8:46 am, Dave Angel<d...@davea.name>  wrote:
>> On 02/07/2012 07:27 AM, Sammy Danso wrote:>  Hello experts,
>>> I am having trouble accessing the content of my list. my
>>> list content has 2-pair value with the exception of one
>>> which has single value. here is an example  ['a', 1, 'b',
>>> 1, 'c', 3, 'd']
>
> First you need to explain why you're using a flat list when a
> number of other structures would be the better choice; like a
> list of tuples or a dict.

I'm not sure there's really a need for the OP to explain 
why...perhaps the data comes from an untrusted (or incompetent) 
source and the routine the OP is asking about is to *create* such 
a list-of-tuples or a dict.

The more important question is what the user/app wants to do when 
such a case is encountered:  do they want to ignore the unpaired 
value, or do they want to pad it with a default value?

-tkc


Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: iterating over list with one mising value Dave Angel <d@davea.name> - 2012-02-07 09:46 -0500
  Re: iterating over list with one mising value Rick Johnson <rantingrickjohnson@gmail.com> - 2012-02-07 07:34 -0800
    Re: iterating over list with one mising value Tim Chase <python.list@tim.thechases.com> - 2012-02-07 10:34 -0600

csiph-web