As per python 3 - removed callable(), replace with if isinstance(f, collections.Callable)