Tuple parameter unpacking in 3.x

Martin Geisler mg at daimi.au.dk
Sat Oct 4 16:57:23 EDT 2008


Dennis Lee Bieber <wlfraed at ix.netcom.com> writes:

> On Sat, 04 Oct 2008 13:14:40 +0200, Peter Otten <__peter__ at web.de>
> declaimed the following in comp.lang.python:
>
>> In 3.0 it has to be rewritten as
>> 
>> def f(ab):
>>     a, b = ab
>>     return a*b
>> 
>> i. e. it needs a statement and an expression and is therefore no
>> longer suitable for a lambda.
>>
>
> 	Given that most lambda's are rather short, is it really that
> much of a pain to just use (for the above example) ab[0]*ab[1] without
> unpacking?

Well -- it is because the code used to be short and sweet that it feels
ugly to me to change

  lambda (a, b): a * b

into

  lambda ab: ab[0] * ab[1]

The first looks perfect -- it matches the math behind the code that I am
writing. The second does not look so nice.

From reading the PEP-3113 I got the impression that the author thought
that this feature was unused and didn't matter. With this I wish to say
that it matters to me.

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multi-Party Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 202 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20081004/cd417bec/attachment.sig>


More information about the Python-list mailing list