[Python-3000] PEP 3132: Extended Iterable Unpacking

Greg Ewing greg.ewing at canterbury.ac.nz
Tue May 8 00:44:15 CEST 2007

Daniel Stutzbach wrote:

> The use came I'm thinking of is this:
> A container type or an iterable where the first few entries contain
> one type of information, and the rest of the entries are something
> that will either be discard or run through for-loop.

If you know you're dealing with an iterator x, then
after a, b, c, *d = x, d would simply be x, so all
you really need is a function to get the first n
items from x.

> I'm suggesting, that:
> - lists return lists
> - tuples return tuples
> - XYZ containers return XYZ containers
> - non-container iterables return iterators.

How do you propose to distinguish between the last
two cases? Attempting to slice it and catching an
exception is not acceptable, IMO, as it can too
easily mask bugs.


More information about the Python-3000 mailing list