newsgroups at jhrothjr.com
Sun Jan 4 00:34:25 CET 2004
"gong" <gongli at cutey.com> wrote in message
news:9abf3a27.0401031446.4d73cfb2 at posting.google.com...
> i would like to pickle a lambda; according to the library docs in 2.3,
> i believe this shouldnt be possible, since a lambda is not a function
> defined at the top level of a module (?)
> however, upon google searching for "python lambda pickle" i find 2
> posts, one including gvr, which apparently demonstrate that this was
> being attempted and even suggest that it is feasible. has this become
> available yet, or will it be soon?
Why do you want to do this? According to the docs, all that
is saved for a function or a class is the name. Code, data and
so forth is not saved, so it makes no sense to try to pickle
a lambda unless you've bound it to a name at the module
level. See 3.14.4 (Python 2.3.3 Library Reference.)
If you really want to serialize a function's code, look at
the marshal module.
More information about the Python-list