Fun with fancy slicing

Fernando Perez fperez528 at yahoo.com
Mon Oct 6 13:09:38 EDT 2003


Alex Martelli wrote:

> I would want the type of the rhs to be irrelevant, just as long as it's any
> iterable whatsoever, and bundle the 'excess items' into ONE specified
> kind of sequence.  I also think it would be best for that one kind to be
> tuple, by analogy to argument passing: you can use any iterable as the
> actual argument 'expanded' by the *foo form, but whatever type foo
> is, if the formal argument is *bar then in the function bar is a TUPLE --
> period, simplest, no ifs, no buts.  Maybe using a list instead might have
> been better, but tuple was chosen, and I think we should stick to that
> for unpacking, because the analogy with argument passing is a good
> part of the reason the *foo syntax appeals to me (maybe for the same
> reason we should at least for now forego the *foo appearing in any
> spot but the last... though that _would_ be a real real pity...).

Agreed: a single convention (and following tuples is a good one, if nothing
else b/c it's the existing one) is probably the sanest solution.  I hadn't
thought of generators and arbitrary iterables, partly b/c I still use pretty
much 'naked' python 2.1 for everything.

Cheers,

f.





More information about the Python-list mailing list