iterating over lines in a file

Remco Gerlich scarblac-spamtrap at pino.selwerd.nl
Thu Jul 20 02:36:51 EDT 2000


nobody wrote in comp.lang.python:
> (fwiw, my prefeerence for this stems mostly from a liking for brevity;

There's another common idiom noone mentioned yet:

import fileinput

for line in fileinput.input("somefile"):
   process(line)

(it opens it for you too)
-- 
Remco Gerlich,  scarblac at pino.selwerd.nl
Hi! I'm a .sig virus! Join the fun and copy me into yours!



More information about the Python-list mailing list