[Python-ideas] 'default' keyword argument for max(), min()

Jacob Holm jh at improva.dk
Fri Apr 17 02:31:39 CEST 2009


Raymond Hettinger wrote:
>> The discussion has indeed sidetracked with handling the special cases,
>> signature definition and whatnot, 
>
> Does the following code emit 10 or -10?
>
> print(min([], default=10, key=operator.neg))
>

10, obviously. The result is always one of the provided values. The key 
function is only used for selecting which one


- Jacob



More information about the Python-ideas mailing list