while c = f.read(1)

Paul Rubin http
Sun Aug 21 06:10:19 EDT 2005


Reinhold Birkenfeld <reinhold-birkenfeld-nospam at wolke7.net> writes:
> Don't forget
> 
> for line in f:
>     for c in line:
>         # do stuff

As mentioned before, that's careless programming, since it can read
the whole file into memory if the file contains no newlines.



More information about the Python-list mailing list