[Python-3000] PEP 3132: Extended Iterable Unpacking (original) (raw)
Steven Bethard steven.bethard at gmail.com
Thu May 3 18:08:54 CEST 2007
- Previous message: [Python-3000] PEP 3132: Extended Iterable Unpacking
- Next message: [Python-3000] PEP 3132: Extended Iterable Unpacking
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 5/3/07, Simon Percivall <percivall at gmail.com> wrote:
On 2 maj 2007, at 20.08, Guido van Rossum wrote: > [Georg] >>>>>>> a, *b, c = range(5) >>>>>>> a >>>> 0 >>>>>>> c >>>> 4 >>>>>>> b >>>> [1, 2, 3] > > > That sounds messy; only allowing *a at the end seems a bit more > manageable. But I'll hold off until I can shoot holes in your > implementation. ;-)
As the patch works right now, any iterator will be exhausted, but if the proposal is constrained to only allowing the *name at the end, wouldn't a more useful behavior be to not exhaust the iterator, making it similar to: > it = iter(range(10)) > a = next(it) > b = it or would this be too surprising?
In argument lists, *args exhausts iterators, converting them to tuples. I think it would be confusing if *args in tuple unpacking didn't do the same thing.
This brings up the question of why the patch produces lists, not tuples. What's the reasoning behind that?
STeVe
I'm not in-sane. Indeed, I am so far out of sane that you appear a tiny blip on the distant coast of sanity. --- Bucky Katt, Get Fuzzy
- Previous message: [Python-3000] PEP 3132: Extended Iterable Unpacking
- Next message: [Python-3000] PEP 3132: Extended Iterable Unpacking
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]