[Python-Dev] Re: syntactic shortcut - unpack to variably sizedlist

Nick Coghlan ncoghlan at iinet.net.au
Sun Nov 21 04:43:38 CET 2004


Raymond Hettinger wrote:
>>I have no great problem with leaving the a, b, *c = L idea unPEPed if
>>there is
>>interest in leaving the idea 'open', though.
> 
> 
> Yes.  I would like to have it left open.

OK, here's what I'll do in the next draft of the proposed PEP (PEPP?):

1. Add a discussion of the advantages of iunpack over islice:
   - guaranteed minimum length (handy for use with tuple unpacking)
   - return the iterator as the final object (this is nicer when the original 
object is an iterable, rather than an iterator - e.g. a list or tuple)

2. Summarise the use cases as given by the previous proponents of the "a, b, *c 
= S" syntax.

3. Soften the PEP's language regarding the "a, b *c = S" syntax.
   Point out that this is a way to get the functionality in a fairly easy to 
spell form for 2.5 that doesn't require changing Python's syntax.
   itertools.iunpack could serve as a reference for defining the behaviour of
that syntax at a later date.

I find the following to be rather readable:

   a, b, itr = iunpack(S, 2)

"iunpack" is also easy to look up in the documentation index.

If Carlos is amenable, I'll add him as a co-author on the PEP - after all, he's 
the one who sold *me* on the idea of iunpack, and most of the points defending 
it are originally his.

Cheers,
Nick.

-- 
Nick Coghlan               |     Brisbane, Australia
Email: ncoghlan at email.com  | Mobile: +61 409 573 268


More information about the Python-Dev mailing list