3 ms·
I find with cmp there's too much to remember - if a < b do I need to return -1 or 1? With Key it becomes really simple, and powerful: sorted(records, key=l
by aidos 12y ago
I find with cmp there's too much to remember - if a < b do I need to return -1 or 1? With Key it becomes really simple, and powerful:
sorted(records, key=lambda r: (r.city, r.age, r.name))
For me there's a lot less mental overhead with the Key form.
Encoding-wise, hex and base64 are not something I do too often, so their new interfaces don't worry me too much. In the cases you've mentioned you could create a simple wrapper function to deal with it for you.
I guess there's some reason for using bytes instead of strings as the output to the interface, but, as you say, it's definitely non-obvious.
There are lots of things that are a little different in python 3; I would say overwhelmingly for the better, on the whole. There just doesn't seem to be much point fighting against those minor changes when they're easy enough to adapt to.