Suppose you want an element from a list that is minimal in a certain respect. The code you usually see for this is:
Here is a nicer way to do this using the standard library:
This is not only more elegant, but also more efficient because sorting a list is more time consuming than finding the minimal element. When dealing with generators this method uses a lot less memory.