Multiline lamba implementation in python.

Facundo Batista facundo at taniquetil.com.ar
Tue Jun 12 08:57:31 EDT 2007


Josh Gilbert wrote:

> I don't expect multiline lambdas to be added to Python. I'm not so sure that
> that's a bad thing. Regardless, isn't it possible to write your own

Yes, it is a bad thing.

Why? Because it would another way to do something you can do in other
way.

The *only* big value of lambda is than you can code a function in a
small place, like:

  bt = Button(...,...,..., lambda evt: None)

If you want to grow that in multiline, just use a named function:

  def multilinefunct(...):
      ...

Remember that the *only* difference between the two functions is that
one is anonymous, and for other you have to came up with a name (name
that if is well thought, actually adds readibility to your code).

Regards,

-- 
.   Facundo
.
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/





More information about the Python-list mailing list