On Sat, 04 Oct 2008 22:57:23 +0200, Martin Geisler wrote: > Dennis Lee Bieber <[EMAIL PROTECTED]> writes: > >> On Sat, 04 Oct 2008 13:14:40 +0200, Peter Otten <[EMAIL PROTECTED]> >> 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.
Here's another alternative. Compare: >>> x = (2, 3) >>> (lambda (a,b): a*b)(x) 6 with this: >>> (lambda a,b: a*b)(*x) 6 > 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. 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. A tiny chance. -- Steven -- http://mail.python.org/mailman/listinfo/python-list