From: Guillermo G. <gui...@gm...> - 2007-02-09 02:25:30
|
Cull, Tim BGI SF wrote: >> Hello, >> [snip] Hi, >> >> The problem I have is that the lambda function is basically not >> serializable. Does anyone have ideas about how to get around this? >> Alternatively, I'd be even happier if I could extract the text of the >> lambda function instead and send the text across the wire as a >> string--I haven't figured out how to do that yet, either. >> >> Here is my suggestion, instead of send a lambda you can send a callable (i.e: function) and serialize using pickle (see: http://docs.python.org/lib/module-pickle.html). i.e: import pickle def my_anonymous_function(x): return x.getQuantity() filter = JythonFilter() filter.setFunction(pickle.dumps(my_anonymous_function)) #Note: pickle.dumps() return a string meantime... in the other side... #I supouse something like this happen my_anonymous_function = pickle.loads(your_instance.getFunction()) my_anonymous_function(x) -- Guillermo Gonzalez JID: ggonzalez -AT- jabber -DOT- org Linux User #385261 |