<[EMAIL PROTECTED]> writes:
> import itertools
> f = open("blah.txt", "r")
> for c in itertools.chain(*f):
>      print c
>      # ...
> 
> The "f" is iterable itself, yielding a new line from the file every time.
> Lines are iterable as well, so the itertools.chain iterates through each
> line and yields a character.

But that can burn an unlimited amount of memory if there are long
stretches of the file with no newlines.  There's no real good way
around ugly code.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to