readline in while loop

Oren Tirosh oren-py-l at hishome.net
Fri May 23 11:44:42 EDT 2003


On Fri, May 23, 2003 at 01:57:26PM +0000, Andrew Koenig wrote:
> >> f = file("test.txt", 'r')
> >> for line in f:
> >>   print line
> >> f.close()
> 
> Ed> Looks neat. I try to avoid Perl vs. Python flame fest, but are
> Ed> some constructs in Python context-sensitive (like in Perl), or is
> Ed> this some handy use of iterators in class file?
> 
> It relies on the fact that a file is an iterator.

Python == 2.3: a file is an iterator
Python == 2.2: a file has an iterator
Python <= 2.1: What's an iterator?

    Oren





More information about the Python-list mailing list