I think is is best explained with an example. Suppose I have a method that calculates the distances between two vectors and prints it. I also want that method to print the distance measure that was used. The distance measure is given to the function by the caller in the form of a callable object. If the callable is an instance of some class, I can provide the __str__ method to make it print out the name of the distance measure. But the callable can also be a function, and I have not found a way to change __str__ in that case. Some code:
def distance(v1, v2, d):
    print d
    dist = d(v1, v2)
    print dist
    return dist
If d is a function, print d will print out something like <function someFunc at 0x1b68830>. How can I change this? Just printing out the name of the function would be fine, since I usually give them readable names.
 
     
     
     
     
    