Martin Geisler: > ci.addCallback(lambda (ai, bi): ai * bi) > or > map(lambda (i, s): (field(i + 1), s), enumerate(si)) > Rewriting these to > ci.addCallback(lambda abi: abi[0] * abi[1]) > and > map(lambda is: (field(is[0] + 1), is[1]), enumerate(si)) > makes the code much uglier! And slightly longer.
I agree a lot. I can show similar examples of my code with sort/sorted that contain a lambda that de-structures sequences of 2 or 3 items, to define a sorting key. As I've stated in the past, I'd like to see more support of pattern matching in Python, and not less. People coming from Mathematica, Scala, OcaML, etc, know they can be useful, and Scala shows that Python too may find some usages for that. I think they have removed (part of, not fully) this Python feature mostly to simplify the C implementation of CPython. So far I think this removal, and not using {:} as empty array literal are the only two mistakes done during the design of Python 3. If you look at the really large number of design decisions taken during the creation of Python 3 itself, I think this is an exceptionally good result anyway. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list