while loop with f.readline()
Chris Gonnerman
chris.gonnerman at usa.net
Tue Feb 13 20:06:25 EST 2001
----- Original Message -----
From: "Chris Richard Adams" <chrisa at ASPATECH.COM.BR>
Subject: while loop with f.readline()
>
>I'm trying to create a loop that reads through a simple file with
>strings on each line.
>
>f=open('/tmp/xferlog', 'r')
>while f.readline():
> line = f.readline()
> print line
I have always been a fan of the FileReader class:
class FileReader:
def __init__(self, file):
self.file = file
def next(self):
self.line = self.file.readline()
return self.line
if __name__ == '__main__':
f = FileReader(open("c:/autoexec.bat"))
while f.next():
print f.line,
More information about the Python-list
mailing list