def get_callable_name(o):
    # special case partial objects
    if isinstance(o, partial):
        keywords = o.keywords
        kwds = (
            ', '.join('%s=%r' % item for item in keywords.items())
            if keywords else
            ''
        )
        args = ', '.join(map(repr, o.args))
        arguments = []
        if args:
            arguments.append(args)
        if kwds:
            arguments.append(kwds)
        return 'partial(%s, %s)' % (
            get_callable_name(o.func),
            ', '.join(arguments),
        )

    try:
        # python 3 makes builtins look nice
        return o.__qualname__
    except AttributeError:
        try:
            # show the module of the object, if we can
            return '%s.%s' % (inspect.getmodule(o).__name__, o.__name__)
        except AttributeError:
            try:
                # __self__ tells us the class the method is bound to
                return '%s.%s' % (o.__self__.__name__, o.__name__)
            except AttributeError:
                # exhausted all avenues of printing callables so just print the
                # name of the object
                return o.__name__
Welcome to str inception. Leave your kittens at home.
dataset/ETHPy150Open blaze/blaze/blaze/expr/core.py/get_callable_name