from functools import reduce


def rec_hasattr(obj, attr):
    """
        Recursive hasattr.

        :param obj:
            The top-level object to check for attributes on
        :param attr:
            Dot delimited attribute name

        Example::

            rec_hasattr(obj, 'a.b.c')
    """
    try:
        reduce(getattr, attr.split('.'), obj)
    except AttributeError:
        return False
    else:
        return True