Apply a function on the attributes of the data

    :param data: an object
    :param fn: a function
    :param attrs: some attributes of the object
    :returns: an object

    Let's create some data first::

        >>> from collections import namedtuple
        >>> Person = namedtuple('Person', ('name', 'age', 'gender'))
        >>> alice = Person('Alice', 30, 'F')

    Usage::

        >>> make_csv_row = lambda n, a, g: '%s,%d,%s' % (n, a, g)
        >>> use_with(alice, make_csv_row, 'name', 'age', 'gender')
        'Alice,30,F'

def use_with(data, fn, *attrs):
    """Apply a function on the attributes of the data

    :param data: an object
    :param fn: a function
    :param attrs: some attributes of the object
    :returns: an object

    Let's create some data first::

        >>> from collections import namedtuple
        >>> Person = namedtuple('Person', ('name', 'age', 'gender'))
        >>> alice = Person('Alice', 30, 'F')

    Usage::

        >>> make_csv_row = lambda n, a, g: '%s,%d,%s' % (n, a, g)
        >>> use_with(alice, make_csv_row, 'name', 'age', 'gender')
        'Alice,30,F'

    """
    args = [getattr(data, x) for x in attrs]
    return fn(*args)