[Python-Dev] itemgetter/attrgetter extension

Raymond Hettinger raymond.hettinger at verizon.net
Tue Mar 8 23:43:54 CET 2005

Any objections to extending itemgetter() and attrgetter() to be able to
extract multiple fields at a time?

    # SELECT name, rank, serialnum FROM soldierdata
    map(attrgetter('name', 'rank', 'serialnum'), soldierdata)

    # SELECT * FROM soldierdata ORDER BY unit, rank, proficiency
    sorted(soldierdata, key=attrgetter('unit', 'rank', 'proficiency'))

Raymond Hettinger

More information about the Python-Dev mailing list