If you do more than a little of this then you could use something like a decorator.
def with_x(x, fn, name=None):
def foo(*args, **kwargs):
return fn(x, *args, **kwargs)
if name:
foo.__name__ = name
return foo
def example(x,y):
return x**y
g = with_x(2, example)
g(3) #8
Use name = parameter
if you care about the __name__
of the resulting function. You could get fancier with other hacks into the enclosed function innards possibly using the __inspect__
module if need be. But then you have re-written the previously mentioned functools
partial stuff just to avoid having to give keyword arguments.