beginning index for generators

Andrew Dalke adalke at
Sun Oct 17 12:35:55 CEST 2004

Peter Otten
> No. That's what I would like xrange() to be.

Ahh, I had forgotten about that restriction.

BTW, this is kinda cute with your code

 >>> list(irange("A", "AAAAAAAAA", "A"))

>>And that's itertools.islice?
> No, but it _calls_ itertool.islice() as you may have noted :-)
> Its raison d'être is that it allows to pass the start, stop, and step
> attributes of a slice object without looking into the special cases.

Acutally I didn't notice.  I was on my way out the door and didn't
look that closely.  My apologies.

Given the worry you had above about the sys.maxint limit, aren't
you also concerned about the same limits with itertools.islice?

> Yes, unfortunately. Discriminating between dictionaries and lists has been
> deliberately left out. Is there a recommended way to do it? Looking for a
> 'keys' attribute maybe?

No, because there are some data structure which act like both
a list and a dictionary.  Eg, one where the dictionary keys are
strings and the items are stored and accesible via integers
into the sort order.

				dalke at

More information about the Python-list mailing list