[Tutor] Re: Incrementing a line?
Don Arnold
darnold02 at sprynet.com
Tue Dec 9 07:33:02 EST 2003
Shame on me for "lineNum++". Oh well, even Danny makes silly mistakes,
sometimes.
Don
On Dec 9, 2003, at 6:25 AM, Andrei wrote:
> Jim Boone wrote on Tue, 09 Dec 2003 11:54:12 +0000:
>
>> Howdy all, i hope this is the right list for my query, pythons a bit
>> new
>> to me, and I'm trying dto something that I can't figure out:
>>
>> for s in userlog.readlines():
>
> How about (with userlog being a file open for reading):
>
> for line in userlog:
> #code here using line (you may use s instead of line if you like)
>
> The code Don Arnold posted should help you with the rest of your
> question,
> at least as long as you don't get more than one constraint violation
> every
> ten lines. If that may happen, you could keep a list of targetLineNums
> and
> test if lineNum is in targetLineNums in order to print "violation info
> at
> line...". Oh, "lineNum++" in that code should be "lineNum+=1" or
> "lineNum =
> lineNum + 1".
>
> --
> Yours,
>
> Andrei
>
> =====
> Mail address in header catches spam. Real contact info (decode with
> rot13):
> cebwrpg5 at jnanqbb.ay. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V
> ernq
> gur yvfg, fb gurer'f ab arrq gb PP.
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list