itertools comments [Was: Re: RELEASED: Python 2.3a2]

Paul Rubin http
Sat Feb 22 01:24:20 CET 2003


Alexander Schmolck <a.schmolck at gmx.net> writes:
> > >> Not without breaking, e.g., xrange(23, 17923, 12)[15] -- which now
> > >> has a perfectly good result of 203 and would break if xrange
> > >> returned an iterator (or any other non-indexable object).
> > > 
> > > It could always return and indexable iterator.
> > 
> > It would only seem to break such usage as:
> > 
> > N_times = xrange(N)
> > 
> > for i in N_times:
> >     for j in N_times:
> >         process(i, j)
> 
> Excellent point. So it is not an option.

Yuck, I didn't you could do that with xrange.  It's surprising and
somewhat bizarre.




More information about the Python-list mailing list