On 18 Aug 2005 22:21:53 -0700 Greg McIntyre wrote: > f = open("blah.txt", "r") > while True: > c = f.read(1) > if c == '': break # EOF > # ... work on c > > Is some way to make this code more compact and simple? It's a bit > spaghetti. > > This is what I would ideally like: > > f = open("blah.txt", "r") > while c = f.read(1): > # ... work on c
for data in iter(lambda:f.read(1024), ''): for c in data: # ... work on c -- jk -- http://mail.python.org/mailman/listinfo/python-list