[issue22979] Use of None in min and max
Steven D'Aprano
report at bugs.python.org
Sat Dec 13 05:06:37 CET 2014
Steven D'Aprano added the comment:
Even though I agree with closing this issue, there is some support for ignoring certain "missing values" when calculating min() and max(). The draft 2008 revision of IEEE-754 includes two functions maxNum and minNum which silently skip over NANs:
https://en.wikipedia.org/wiki/IEEE_754_revision#min_and_max
The R language also supports max and min skipping over missing values:
https://stat.ethz.ch/R-manual/R-devel/library/base/html/Extremes.html
The problem is that there are so many different things which somebody might want to do, it is hard to tell which (if any) the built-ins should support:
- silently skip over None
- or NANs
- or treat some other, user-specified, value as "missing"
- treat None as the smallest (or largest) value
- treat the presence of None as an error
- etc.
I think that min() and max() should continue to be relatively simple-minded and let users write their own more complex versions if needed, e.g. by calling min(filter(condition, values)).
----------
nosy: +steven.daprano
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22979>
_______________________________________
More information about the Python-bugs-list
mailing list