S
Steve R. Hastings
The list.sort() method accepts a "key=" parameter to let you specify a
function that will change the way it sorts. In Python 2.5, min() and
max() now accept a "key=" parameter that changes how the functions decide
min or max.
Should any() and all() take a key= argument?
Example:
The above could be done with generator expressions:
True
I kind of like the key= option. The need isn't as strong as with
..sort(), min(), and max(), but consistency can be a good thing. I'd
personally like to see key= anywhere it makes sense.
function that will change the way it sorts. In Python 2.5, min() and
max() now accept a "key=" parameter that changes how the functions decide
min or max.
Should any() and all() take a key= argument?
Example:
Truelst = [2, 4, 42]
any(lst, key=lambda x: x == 42) True
all(lst, key=lambda x: x % 2 == 0)
The above could be done with generator expressions:
True
I kind of like the key= option. The need isn't as strong as with
..sort(), min(), and max(), but consistency can be a good thing. I'd
personally like to see key= anywhere it makes sense.