On 4 maj 2007, at 06.13, Greg Ewing wrote: > Simon Percivall wrote: >> 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? > > It would surprise the heck out of me when I started > with something that wasn't an iterator and ended > up with b being something that I could only iterate > and couldn't index.
Yes, that would be surprising. This was more in the way of returning the type that was given: if you start with a list you end up with a list in "b", if you start with an iterator you end up with an iterator. This would enable stuff like using this with itertools.count and other iterators that represent infinite sequences. Also, I'm not intending to argue this, but exhausting the iterator is not exactly like *args in argument lists, because the iterator isn't the name being starred. It's more like the formal parameter of a function, when the receiver of the iterator _is_ starred, but the iterator is not. The iterator isn't automatically exhausted in those cases. //Simon _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com