News for hackers. Stuff that matters.
Re:Widely useful Python utilities by Peter Norvig by yummyfajitas on Monday September 14, 2009 @03:40PM (#822443)
A useful utility I've rarely seen included in such a list is inverse_image(collection, function) which computes the inverse image of the function restricted to the collection.

A simple example:

    students_by_grade = inverse_image(students, lambda s: s.grade)
Then students_by_gender["A"] contains a list of all the A students (and so on).
Re:Widely useful Python utilities by Peter Norvig by jongraehl on Monday September 14, 2009 @07:26PM (#822871)
Agreed - sometimes known as "group by".