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


Groups > comp.lang.python > #44402 > unrolled thread

Re: Nested For loop not running full

Started byOscar Benjamin <oscar.j.benjamin@gmail.com>
First post2013-04-26 10:44 +0100
Last post2013-04-26 10:44 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#44402 — Re: Nested For loop not running full

FromOscar Benjamin <oscar.j.benjamin@gmail.com>
Date2013-04-26 10:44 +0100
SubjectRe: Nested For loop not running full
Message-ID<mailman.1091.1366969475.3114.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web