Trouble using lambda to pass args to event function

Tom Taylor wrote:

Peter Hansen wrote:

Note also that a curry function is available in Python 2.5 in the functools module, called (some more clearly) "partial".

Thanks Peter, I'm sticking with 2.4 for the moment until Ubuntu has the wx library available for 2.5, but I'll bear it in mind in case I switch further down the line.

Technically we're still using 2.4 as well, so we have the following in a utility file (allowing a quiet switchover to the 2.5 function once we switch). As you can see, it's a pretty short, though perhaps not "trivial", function:

try:
     # use library version of partial if available
     from functools import partial

except ImportError:
     def partial(fn, *cargs, **ckwargs):
         '''partial function application, see PEP 309'''
         # This is the implementation of partial function application posted by Carl
         # Banks and included in PEP 309 – Partial Function Application | peps.python.org where it is
         # called "curry".
         def call_fn(*fargs, **fkwargs):
             d = ckwargs.copy()
             d.update(fkwargs)
             return fn(*(cargs + fargs), **d)
         return call_fn

(Hoping the indentation doesn't get screwed up there... )

-Peter