Final state of underlying sequence in islice

Raymond Hettinger python at rcn.com
Fri Nov 5 16:51:32 EDT 2010


On Nov 5, 1:05 pm, Terry Reedy <tjre... at udel.edu> wrote:
> > Currently, there are no promises or guarantees about the final state
> > of the iterator.
>
> I interpret the current doc statement as a promise that becomes
> ambiguous when step > 1.

You may have missed my point.  I wrote the tools, the docs, and the
tests.
If you interpret a "promise" in text, I can assure you it was not
intended.  The behavior *is* undefined because I never defined it.
I'm happy to clarify the docs to make that explicit.

Or I can alter the implementation a bit to make a guarantee
if it looks like there is a good reason to do so.
The OP doesn't have any use cases to light the way
and I don't yet see any useful invariants that would
arise out of either definition.  And since the ambiguity
only shows-up in a somewhat rare case, I'm inclined to
just mark it as undefined.


Raymond




More information about the Python-list mailing list