Need a little parse help

Michael Hartl mhartl at post.harvard.edu
Tue May 10 19:21:42 EDT 2005


I'd also like to note that both the inputfiles variable and the
readlines() method are superfluous; to iterate through the file line by
line, use either

for line in open(inputfilename):
    # do something with line

or (my personal preference, since I like to think of the file as a
thing rather than an action)

for line in file(inputfilename):
    # do something with line

(Note also that the 'r' argument to open/file is the default and so can
be omitted.)

Michael

--
Michael D. Hartl, Ph.D.
CTO, Quark Sports LLC
http://quarksports.com/




More information about the Python-list mailing list