from functools import reduce


def attrgetter(item, default=''):
    """operator.attrgetter with a default value."""
    reducer = lambda obj, name: getattr(obj, name, default)
    return lambda obj: reduce(reducer, item.split('.'), obj)