def name_that_thing(thing):
 if hasattr(thing, 'im_class'):
  if hasattr(thing, 'mock_calls'):
   return '<mock>'
  return ((name_that_thing(thing.im_class) + '.') + thing.im_func.func_name)
 if hasattr(thing, '__name__'):
  if (hasattr(thing, '__class__') and (not isinstance(thing, (types.FunctionType, types.MethodType)))):
   if ((thing.__class__ is not type) and (not issubclass(thing.__class__, type))):
    return name_that_thing(thing.__class__)
  if hasattr(thing, '__self__'):
   return ('%s.%s' % (thing.__self__.__module__, thing.__self__.__name__))
  if hasattr(thing, '__module__'):
   return ('%s.%s' % (thing.__module__, thing.__name__))
 if hasattr(thing, '__class__'):
  return name_that_thing(thing.__class__)
 return repr(thing)

def name_that_thing ( thing ) : if hasattr ( thing , 'im_class' ) : if hasattr ( thing , 'mock_calls' ) : return '<mock>' return ( ( name_that_thing ( thing . im_class ) + '.' ) + thing . im_func . func_name ) if hasattr ( thing , '__name__' ) : if ( hasattr ( thing , '__class__' ) and ( not isinstance ( thing , ( types . FunctionType , types . MethodType ) ) ) ) : if ( ( thing . __class__ is not type ) and ( not issubclass ( thing . __class__ , type ) ) ) : return name_that_thing ( thing . __class__ ) if hasattr ( thing , '__self__' ) : return ( '%s.%s' % ( thing . __self__ . __module__ , thing . __self__ . __name__ ) ) if hasattr ( thing , '__module__' ) : return ( '%s.%s' % ( thing . __module__ , thing . __name__ ) ) if hasattr ( thing , '__class__' ) : return name_that_thing ( thing . __class__ ) return repr ( thing )
returns either the function/class path or just the objects repr .