PEP 276 Simple Iterator for ints

Jeff Shannon jeff at
Fri Nov 16 00:56:43 CET 2001

David Eppstein wrote:

> In article <3BF43EA3.42A5A4B6 at>,
>  Jeff Shannon <jeff at> wrote:
> > > >>> for i in int[2:10:2]: print i,
> > > 2 4 6 8
> > >
> >
> > This doesn't look too bad to me.  I'd go for it.
> Why is int[2:10:2] an improvement over range(2,10,2)?
> They have the same number of words and the same argument values with the
> same amount of punctuation, the only difference to me is that int[2:10:2]
> is in a much less familiar syntax.

Well, to be honest, I have no problem with range()/xrange() as they stand.
You're right, though, in that the int[:] notation doesn't gain anything.
Thus, my vote (for what little it's worth ;) ) is to do nothing, and leave
range()/xrange() as the proper way to do things.

Jeff Shannon
Credit International

More information about the Python-list mailing list