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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'append': 0.07; 'elegant': 0.07; 'pretend': 0.07; 'subject:Question': 0.07; 'advice.': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'anyway': 0.11; "'c'": 0.16; "(i'm": 0.16; 'columns': 0.16; 'increment': 0.16; 'incremented': 0.16; 'repetition': 0.16; 'wrote:': 0.17; 'issue.': 0.20; '31,': 0.22; 'cc:2**0': 0.23; 'monday,': 0.23; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'raw': 0.27; 'arrays': 0.29; 'loop,': 0.29; 'maybe': 0.29; 'december': 0.32; 'could': 0.32; 'print': 0.32; 'another': 0.33; 'agree': 0.34; 'skip:b 20': 0.34; 'received:google.com': 0.34; 'thanks': 0.34; 'list': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'thank': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'your': 0.60; 'you.': 0.61; 'solve': 0.62; 'more': 0.63 Newsgroups: comp.lang.python Date: Mon, 31 Dec 2012 14:02:52 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=129.118.0.5; posting-account=DOyQBwoAAADIEpwWr89vk1x7RGFM33oc References: User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 129.118.0.5 MIME-Version: 1.0 Subject: Re: Question about nested loop From: Isaac Won To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: Python-list 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: , Message-ID: Lines: 55 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356991376 news.xs4all.nl 6901 [2001:888:2000:d::a6]:43287 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35857 On Monday, December 31, 2012 5:25:16 AM UTC-6, Gisle Vanem wrote: > "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 Thank you for your advice. I agree with you and tried to increment in inner loop, but still not very succesful. Anyway many thanks for you.