When you pass a defined function as a callback or event/handler function, say to a thread or multiprocess object, can you get the actual name of the function in executed function?
For example, if I pass Test
, (i.e. def Test()
) to some Python object that needs such a callback during initialization, can I get the name of the function to print before I invoke it? Name from the passed object itself. I tried using __str__ and __repr__, but both return a full descriptor of the pass (function) object... '<function OnProcess..Test at 0xb33f9390>'. I could just parse the string removing '<function', '', and at '0xb33f9390>' elements of string representation of the passed (function) object, ending up with 'OnProcess.Test'. But is there a better way? More elegant way to get just the function name? Can't use inspect module because I have not called the function as yet, so no stack frame, it is just a parameter value at the point I want to get the name.