Lambda alternative?

Hrvoje Niksic hniksic at xemacs.org
Thu Apr 16 11:21:12 CEST 2009


mousemeat <mousemeat at gmail.com> writes:

> Thank you for everyone's explanations, help and interest on this
> one.  I have reworked my code as described and promised myself not
> to use lambdas ever again (i still think they are an elegant idea,
> but if they are incompatible with frequently used modules, then the
> inelegance of reality quickly overshadows the elegance of the
> theory).

I think you're going too far concluding that lambdas are unusable.
lambdas are a problem only when they are stored as data attributes
that need to be pickled, but that's far from being the only use case.
You can still use them for what they're meant to be used: tiny anonymous
function-expressions, typically passed as parameters to functions that
expect a callback.

Avoiding lambdas because they're unpicklable is like avoiding bound
methods because they're just as unpicklable.



More information about the Python-list mailing list