Strange range

Marko Rauhamaa marko at pacujo.net
Sat Apr 2 17:40:22 EDT 2016


Chris Angelico <rosuav at gmail.com>:

> On Sun, Apr 3, 2016 at 6:44 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> I don't have a problem with a list being a "reiterable." I only was
>> surprised about range(), which I had thought to be a plain,
>> down-to-earth iterator. There's barely any other practical use for a
>> range, I believe.
>
> That's Blub's Paradox right there. There are lots of other uses for
> range(), but you just haven't used them.

That's why I was looking for counterexamples in the standard library
sources but couldn't really spot any (apart from a single
reversed(range())). Maybe I wasn't looking carefully enough.

As far as I can tell, range() is simply Python's way of implementing
classical integral "for" loops.


Marko



More information about the Python-list mailing list