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'))
Breaking the symmetry with getattr() bothers me a little, as does the signature change that occurs when multiple arguments are given (returning a tuple, whereas the single argument returns just the retrieved attribute).
For itemgetter, I'd like to see multiple arguments eventually map to multi-dimensional slices (to preserve symmetry with indexing syntax).
Call it -1 for itemgetter and -0 for attrgetter.
Cheers, Nick.
-- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.skystorm.net _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com