better lambda support in the future?

Nick Coghlan ncoghlan at
Sat Dec 18 07:35:31 CET 2004

Jp Calderone wrote:
 >   Regarding #1: there must be a great variance between people in the
 > difficulty of some aspects of programming.  I am always amazed to hear
 > from people who have no difficulty picking names for all of their
 > functions.  This is a task that often stumps me for long minutes.

My answer to this: cheat

If the important thing about the function is the fact that it *is* a function, 
"func" or "_func" is a perfectly acceptable name. Heck, you could use 
"lamda_func" if you really wanted to :)

So, something like:

some_call(x, lamba a, b, c: (a - c, b - a, c - b), y, z)


def _func(a, b, c):
   return a - c, b - a, c - b
some_call(x, _func, y, z)

I also believe the second version makes it far more obvious what is going on:
  1. We're creating a function which takes 3 arguments
  2. The function returns the differences between them
  3. That function is then passed as an argument to another function call

All of that is contained in the lambda version, too, but the excessive brevity 
makes for rather confusing reading.


Nick Coghlan   |   ncoghlan at   |   Brisbane, Australia

More information about the Python-list mailing list