beginning index for generators

Andrew Dalke adalke at mindspring.com
Sat Oct 16 23:39:05 EDT 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?

				Andrew
				dalke at dalkescientific.com



More information about the Python-list mailing list