Lambda alternative?

mousemeat mousemeat at
Thu Apr 16 12:25:30 CEST 2009

On 16 Apr, 10:21, Hrvoje Niksic <hnik... at> wrote:
> mousemeat <mousem... at> 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.

Correct me if i am wrong, but i can pickle an object that contains a
bound method (it's own bound method).  I cannot pickle an object that
contains a lambda function.  Doesn't that make lambda's less
pickleable?  (I don't mean to be argumentative, i'm trying to
understand python's syntax a little better.)

More information about the Python-list mailing list