def object_name(obj):
    """Get the qualified name of an object. This will obtain both the module
    name from `__module__` and object name from `__name__`, and concatenate
    those with a '.'. Examples:

    >>> from math import sin
    >>> object_name(sin)
    'math.sin'

    >>> def f(x):
    ...     return x*x
    ...
    >>> object_name(f)
    '__main__.f'

    To have a qualified name, an object must be defined as a class or function
    in a module (``__main__`` is also a module). A normal instantiated object
    does not have a qualified name, even if it is defined and importable from a
    module.  Calling |object_name| on such an object will raise
    :py:exc:`AttributeError`.

    .. |object_name| replace:: :py:func:`object_name`"""
    return obj.__module__ + '.' + obj.__qualname__
