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


Groups > comp.lang.python > #35848

Re: Question about nested loop

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <gvanem@broadpark.no>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'append': 0.07; 'elegant': 0.07; 'pretend': 0.07; 'subject:Question': 0.07; 'to:name:python- list': 0.15; "'c'": 0.16; "(i'm": 0.16; 'columns': 0.16; 'incremented': 0.16; 'repetition': 0.16; 'wrote:': 0.17; 'issue.': 0.20; 'x-mailer:microsoft outlook express 6.00.2900.5931': 0.22; 'raw': 0.27; 'arrays': 0.29; 'maybe': 0.29; 'could': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'another': 0.33; 'skip:b 20': 0.34; 'list': 0.35; 'there': 0.35; 'but': 0.36; 'charset:us-ascii': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'your': 0.60; 'solve': 0.62; 'more': 0.63
MIME-version 1.0
Content-transfer-encoding 7BIT
Content-type text/plain; CHARSET=US-ASCII; format=flowed; reply-type=original
From Gisle Vanem <gvanem@broadpark.no>
To Python-list <python-list@python.org>
References <db8edd31-78f2-4e8c-a6bd-37e1e83ff2ee@googlegroups.com>
Subject Re: Question about nested loop
Date Mon, 31 Dec 2012 12:25:16 +0100
X-Priority 3
X-MSMail-priority Normal
X-Mailer Microsoft Outlook Express 6.00.2900.5931
X-MIMEOLE Produced By Microsoft MimeOLE V6.00.2900.6157
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 <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.1497.1356956797.29569.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1356956797 news.xs4all.nl 6895 [2001:888:2000:d::a6]:34432
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:35848

Show key headers only | View raw


"Isaac Won" <winefrog@gmail.com> wrote:

> while c < 10:
>        c = c + 1
> 
>        for  columns in ( raw.strip().split() for raw in f ):
> 
> 
>                b.append(columns[c])
> 
>        y = np.array(b, float)
>        print c, y
> 
> 
> I thought that  can get the arrays of the columns[5] to [10],
> but I only could get repetition of same arrays of columns[5].

I don't pretend to know list comprehension very well, but 
'c' isn't incremented in the inner loop ( .. for raw in f). 
Hence you only append to columns[5].

Maybe you could use another 'd' indexer inside the inner-loop?
But there must a more elegant way to solve your issue. (I'm a
PyCommer myself).

--gv

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


Thread

Question about nested loop Isaac Won <winefrog@gmail.com> - 2012-12-31 02:02 -0800
  Re: Question about nested loop Gisle Vanem <gvanem@broadpark.no> - 2012-12-31 12:25 +0100
    Re: Question about nested loop Isaac Won <winefrog@gmail.com> - 2012-12-31 14:02 -0800
    Re: Question about nested loop Isaac Won <winefrog@gmail.com> - 2012-12-31 14:02 -0800
  Re: Question about nested loop Hans Mulder <hansmu@xs4all.nl> - 2012-12-31 13:59 +0100
    Re: Question about nested loop Isaac Won <winefrog@gmail.com> - 2012-12-31 14:11 -0800

csiph-web