program in interactive mode

Scott David Daniels Scott.Daniels at Acm.Org
Sun Dec 26 22:20:50 CET 2004


B.G.R. wrote:
> numline=0
> for line in sys.stdin:
>     numline+=1
>     workwithline(line)

I'd use:

     for numline, line in enumerate(sys.stdin):
         workwithline(line)

Note: The line numbers start at 0, but that is often acceptable.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list