PEP 260: simplify xrange()
Just van Rossum
just at letterror.com
Fri Jun 29 02:25:40 EDT 2001
Grant Griffin <not.this at seebelow.org> writes:
> 2) How do the functions from xrange relate--semantically speaking--to
> the functions of "xreadlines()"? It seems to me that the two should
> have a similar "user interface" because they work about the same way,
> and solve similar problems.
Guido van Rossum wrote:
> xreadlines() already follows the new xrange() philosophy. Even
> better, xreadlines() allows you to loop over it only once, and you
> have to use the natural indexing sequence. This makes it easier to
> turn xreadlines() into a pure iterator -- this can't be done with
> xrange(), because of the following common idiom:
>
> r = xrange(1000000)
> for i in r: f1()
> for i in r: f2()
Erm, now that "for line in file" works (in 2.2 that is), doesn't that
mean that xreadlines() is superfluous? Or: what does xreadlines() offer
that "for line in file" doesn't?
Just
More information about the Python-list
mailing list