how to pickle a lambda?

Alejandro Dubrovsky s328940 at student.uq.edu.au
Tue Apr 30 00:42:54 EDT 2002


On Tue, 30 Apr 2002 09:31:10 +1000, Paul Rubin wrote:


>> 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.
 
well, that's right, you can't.  that's why i was pickling functions by
storing their .__name__

Alejandro



More information about the Python-list mailing list