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


Groups > comp.lang.python > #44402

Re: Nested For loop not running full

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.095
X-Spam-Evidence '*H*': 0.83; '*S*': 0.02; 'subject:not': 0.03; 'cc:addr:python-list': 0.11; 'coordinates': 0.16; 'loops': 0.16; 'once.': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'reset': 0.22; 'cc:addr:python.org': 0.22; 'replace': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; '(unless': 0.31; 'ball': 0.31; 'file': 0.32; 'run': 0.32; 'text': 0.33; 'says': 0.33; 'running': 0.33; 'fri,': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'list': 0.37; 'pm,': 0.38; 'times': 0.62; 'to:addr:gmail.com': 0.65; '26,': 0.68; 'subject:For': 0.78; 'oscar': 0.84; 'otten': 0.84; 'dirty': 0.93; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=06cDDfJYH0zPwR13sTx/NPntT6rK7El+ct2VX0qrdKA=; b=dLMNlwwPpOzmhmETqAecCQa2v+GqxUb6eeXoPYBnPz4u7H5R/W7qUA20XyPp5EkCEQ zpCnogzLTxaGzjmm7Fz+4IiemXqedyeu+I7lFi07QQgyKzwcQJAjgc9kRa8u7u6AZeKH KBuN/LN+NPTqk6EQUUqJzdF2Aqjoq4uFt//rIzCmTsYNt+7gNiikyYqf2MnvaPHN/7le Y1HgNC+kmVg2PLzM34tLqHQgRmSIWclzeFuTfREpvRPl6eJLvhk77T52V9K6jxj2m2DT I/PTyd1fmWDZvTAjz0JaZqjjVVtDxO9VQMqZ4lmuJirjpxuph8oP4A7m3t+9GC/vFtgd NXIg==
X-Received by 10.220.146.82 with SMTP id g18mr20847071vcv.54.1366969466351; Fri, 26 Apr 2013 02:44:26 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CAFqGZRGoh=hTG7PZgxNaaKgq8Z_QHyqVQZ+voe1z_KY+-ysjug@mail.gmail.com>
References <CAFqGZRF4s_+9R4qDZTmFD7OWWMTn_YnhjKNMh8gY97ng5tyr9g@mail.gmail.com> <kldg7b$20b$1@ger.gmane.org> <CAFqGZRGoh=hTG7PZgxNaaKgq8Z_QHyqVQZ+voe1z_KY+-ysjug@mail.gmail.com>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date Fri, 26 Apr 2013 10:44:06 +0100
Subject Re: Nested For loop not running full
To inshu chauhan <insideshoes@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Cc "python-list@python.org" <python-list@python.org>
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.1091.1366969475.3114.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366969475 news.xs4all.nl 15999 [2001:888:2000:d::a6]:48279
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44402

Show key headers only | View raw


On 26 April 2013 10:36, inshu chauhan <insideshoes@gmail.com> wrote:
>
> On Fri, Apr 26, 2013 at 2:39 PM, Peter Otten <__peter__@web.de> wrote:
>>
>> My crystal ball says that the 'for sy...' and 'for sx...' loops are
>> running
>> to completion, but you don't get the coordinates printed because you put
>> them into the 'for l in f' loop which will only run once.
>
> Is there any means by which I can run this 'For l in f' loop again and again
> ?
>>
>> The quick and dirty fix is to replace
>>
>> f = open(...)
>>
>> in the code you are not showing with
>>
>> f == list(open(...))
>
> f is just a text file(csv format).. so why list ??

So that you can run the for l in f loop again and again. You can loop
over a list as many times as you like but only once over a file
(unless you reset the file pointer).


Oscar

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


Thread

Re: Nested For loop not running full Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-26 10:44 +0100

csiph-web