def attr(name):
    """Produces a function that accesses an attribute

    :param name: Name of an attribute
    :returns: A function that when applied to an instance returns the
              value for the attribute 'name'
    :rtype: function

    """

    def _attr(obj):
        """Wrapped function for accessing an attribute

        The attribute 'name' is defined in the enclosing closure.

        :param dictionary: an object
        :returns: Value of the 'name' attribute or ''
        """
        return getattr(obj, name) if hasattr(obj, name) else ''

    return _attr