Tuple parameter unpacking in 3.x

Martin Geisler mg at daimi.au.dk
Sun Oct 5 04:38:43 EDT 2008


Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:

> On Sat, 04 Oct 2008 22:57:23 +0200, Martin Geisler wrote:
>
> Here's another alternative. Compare:
>
>>>> x = (2, 3)
>>>> (lambda (a,b): a*b)(x)
> 6
>
> with this:
>
>>>> (lambda a,b: a*b)(*x)
> 6

Letting the callbacks take several arguments would definitely be the
nicest syntax, but I'm unfortunately restricted by the Twisted
framework: there all functions in a callback chain return one result
which is passed to the next callback as the first argument. That is why
I do a fair amount of tuple unpacking in my code.

>> 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.
>
> Alas, I think it's too late. I feel your pain.

Thanks! And I know it's too late, I should have found out about this
earlier :-(

> The final release of Python 3.0 hasn't been made yet. If you really
> care strongly about this, you could write to the python-dev mailing
> list and ask if it is worth trying to change their mind about tuple
> unpacking. They'll almost certainly say no, but there's a chance it
> might be reverted in 3.1.

I can't see this being changed back and forth like that, so I don't
think I'll bother. But thanks for the support.

-- 
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/20081005/6841acf6/attachment.sig>


More information about the Python-list mailing list