[Tutor] range as a not-quite-iterator

Jim Mooney cybervigilante at gmail.com
Sun Aug 4 04:17:14 CEST 2013


On 3 August 2013 19:03, Steven D'Aprano <steve at pearwood.info> wrote:

while range objects can be re-used, and also can be sliced almost
> like a list.
>
> py> r[1:3]
> range(5, 11, 3)

Ah, that makes them much more useful. I was wondering a while back if
I had to go through the entire range to get part of the sequence, but
didn't think of slicing the range since it seemed too dynamic.

-- 
Jim
The Curiosity Rover has been on Mars a year Huh? It feels like it
landed, at most, a few months ago. Where in hell is the time going?


More information about the Tutor mailing list