[Python-ideas] 'default' keyword argument for max(), min()
Raymond Hettinger
python at rcn.com
Wed Apr 15 20:22:42 CEST 2009
[Adam Atlas]
> > I propose adding a "default" keyword argument to max() and min(),
> >which provides a value to return in the event that an empty iterable is passed.
[Tal Einat]
> +1
>
> This has precedent in reduce()'s "initial" keyword argument; note that min()
> and max() are really simple special cases of reduce().
Of course, what he is proposing has completely different semantics
than an intial argument. If anyone finds that distinction to be confusing,
then we would have a good reason not to accept the proposal.
min([1,2], initial=0) --> 0
min([1,2], default=0) --> 1
Raymond
More information about the Python-ideas
mailing list