[SciPy-user] stupid python question : for in in range(nlines) :
Eric Emsellem
emsellem at obs.univ-lyon1.fr
Thu Apr 20 12:13:33 EDT 2006
Hi,
I have a very dum python question here, hopefully someone can answer
this in no time:
I have a script including lines such as (reading a file with "nlines"
lines):
##############################
for i in range(nlines) :
...
...
while i < nlines :
....
i += 1
if ... :
break
#############################
But of course the "while" loop changes the increment "i", but then, when
the break condition is valid, it returns to the "for" loop and starts
again with the set of lines WITHOUT taking into account the fact that
"i" was incremented (so that it should not read these lines AGAIN).
Hope this is clear. Let me know if you have a simple solution (my
scripting habits are coming from C, hence the way I stupily wrote things
here...)
Thanks in advance for any help there
Eric
More information about the SciPy-User
mailing list