In <ib1fai$8g3$0...@news.t-online.com> Peter Otten <__pete...@web.de> writes:
>gb345 wrote: >> For a project I'm working on I need a way to retrieve the source >> code of dynamically generated Python functions. (These functions >> are implemented dynamically in order to simulate "partial application" >> in Python.[1]) >Are you aware of functools.partial? >>>> from functools import partial >>>> def f(a, b, c, x, y, z): >... return a*x + b*y*y + c*z*z*z >... >>>> fstar = partial(f, x=1, y=2, z=3) >>>> fstar(1, 0, 0) >1 >>>> fstar(0, 1, 0) >4 >>>> fstar(0, 0, 1) >27 >>>> fstar.args, fstar.keywords >((), {'y': 2, 'x': 1, 'z': 3}) >>>> fstar.func ><function f at 0x7fc4868e6848> I was not aware of functools.partial. This makes the problem a lot easier. Thanks! G -- http://mail.python.org/mailman/listinfo/python-list