callbacks in python

Fredrik Lundh fredrik at
Wed Aug 13 23:02:35 CEST 2008

Alexandru Mosoi wrote:

> does anyone know a nice implementation of callbacks in python? i have
> issues mixing named & unamed parameters. i want build a callback over
> a function such that some parameters are passed when callback is
> created and the rest are passed when the function is called.
> example:
> callback = Callback(function, x=1, y)
> callback(z, t=4, u)

your use of the word "callback" is a bit unusual, and your example isn't 
valid Python code, but it looks as if functools.partial might be what 
you need:


More information about the Python-list mailing list