Martin Manns wrote:
Hi,
I try to get a set of lambda functions that allows me executing each
function code exactly once. Therefore, I would like to modify the set
function to compare the func_code properties (or the lambda
functions to use this property for comparison).
(The reason is that the real function list is quite large (> 1E5), there
are only few functions with non-equal code and the order of execution
is not important.)
How can I achieve this?
func_strings=['x', 'x+1', 'x+2', 'x']
funclist = [eval('lambda x:' + func) for func in func_strings]
What are you actually trying to do, anyway? What's the application?
You probably don't want to use "eval" that way. If you want function
objects out, use "compile".
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list