Adam DePrince wrote:
Lets not forget the "real reason" for lambda ... the elegance of
orthogonality. Why treat functions differently than any other object?


We can operate on every other class without having to involve the
namespace, why should functions be any different?

Yup. I think in most of the examples that I didn't know how to rewrite, this was basically the issue. On the other hand, I do think that lambdas get overused, as indicated by the number of examples I *was* able to rewrite.[1]


Still, I have to admit that in some cases (especially those involving reduce), I wish the coder had named the function -- it would have given me a little bit more documentation as to what the code was trying to do.

On the other hand, in other cases, like when a function is a keyword argument to another function (e.g. inspect.py's "def formatargspec..." example) using a def statement and naming the function would be redundant.

Steve

[1] Note that this isn't entirely fair to the examples, some of which were written before list comprehensions, generator expressions and itemgetter/attrgetter.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to