[Python-Dev] Half-baked proposal: * (and **?) in assignments

Oren Tirosh oren-py-d@hishome.net
Sun, 24 Nov 2002 03:33:16 -0500


On Sun, Nov 24, 2002 at 09:03:20AM +0100, Alex Martelli wrote:
> def peel(iterator, arg_cnt=2):
>     iterator = iter(iterator)
>     for num in xrange(arg_cnt):
>         yield iterator.next()
>     yield iterator

I like this function, but the argument name is misleading - it isn't 
necessarily an iterator. In the common use cases it will be a list or 
tuple.

def peel(iterable, arg_cnt=2):
    iterator = iter(iterable)
    for num in xrange(arg_cnt):
        yield iterator.next()
    yield iterator

The name 'iterable' is unambigous but a little awkward. I'd like to 
use the term 'sequence' but I'm afraid people already associate it 
with the built-in sequence types or with something indexable rather 
than iterable. Do you think of iterators as a sequences?

	Oren