Peter Otten <[EMAIL PROTECTED]> writes: > Nick Craig-Wood wrote: > >> So just remove the parentheses and you'll be fine. > > No, you change the function signature in the process. > > f = lambda (a, b): a*b > > is equivalent to > > def f((a, b)): # double parens > return a*b > > and called as f(arg) where arg is an iterable with two items. > > 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.
Exactly! Maybe it is the callback-heavy programming style encouraged by Twisted that is at fault here, but I quite like it and am sorry to see it made more difficult. A somewhat related question: do I pay a performance penalty when I let a function define an inner function like this: def foo(): def bar() ... bar() compared to just defining it once outside: def bar(): ... def foo(): ... bar() I'm thinking that each execution of the first foo could spend a little time defining a new bar each time, or is that not how things work? I realize that defining bar as an inner function has the advantage of being able to see variables in the namespace of foo. -- Martin Geisler VIFF (Virtual Ideal Functionality Framework) brings easy and efficient SMPC (Secure Multi-Party Computation) to Python. See: http://viff.dk/.
pgp8h0HQCkWkD.pgp
Description: PGP signature
-- http://mail.python.org/mailman/listinfo/python-list