how to pickle a lambda?
Paul Rubin
phr-n2002a at nightsong.com
Mon Apr 29 19:31:10 EDT 2002
Kragen Sitaker <kragen at pobox.com> writes:
> Unfortunately not. You can't marshal lambdas either.
Oh well. I'm surprised by this. Maybe marshal should be extended.
> Or you can just use named functions, especially if you don't have
> closure data.
I thought a named function was just a variable whose value was a lambda:
def square(x): return x*x
is the same as
square = lambda x: x*x
Of course the syntax is different (you can't have control statements in
a lambda) but I'd have thought if you can't marshal a lambda, you also
can't marshal a named function.
More information about the Python-list
mailing list