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: 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 To: Python-list References: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 "Isaac Won" 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