beginning index for generators

Andrew Dalke adalke at
Sun Oct 17 05:39:05 CEST 2004

Peter Otten wrote:
> def irange(start, stop, step):

Isn't that xrange?

> def islice(iterable, start, step, stop):

And that's itertools.islice?

> class iterate(object):
>     def __init__(self, iterable):
>         self.iterable = iterable
>     def __getitem__(self, s):
>         if not isinstance(s, slice):
>             raise ValueError("supports only slices")
>         start, stop, step = s.start, s.stop, s.step
>         if hasattr(self.iterable, "__getitem__"):

And doesn't that test fail for dictionaries?

				dalke at

More information about the Python-list mailing list