I want to change the string representation of a python function to be just the function name.
Eg for some function
def blah(x): ...
As Joran said:
class NamedFunction: def __init__(self, name, f): self.f = f self.name = name def __call__(self, *args, **kwargs): return self.f(*args, **kwargs) def __str__(self): return self.name f = NamedFunction("lambda: 'blah'", lambda: 'blah') print(f()) print(f)