"Michael Hartl" <[EMAIL PROTECTED]> writes: > 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
I'd like to note that failing to close the file explicitly is a bad habit. You really should invoke the close method, rather than relying on the garbage collector to close them for you. This means you do need a variable to hold the file object. 99% of the time nothing bad will happen if you skip this, but that 1% can always come back to byte you in the *ss. <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list