[Python-ideas] Have max and min functions ignore None

Gerald Britton gerald.britton at gmail.com
Tue Dec 29 18:02:09 EST 2015


On *Tue Dec 29 06:22:58 EST 2015, Stephen D'Aprano wrote:*


> So that's three perfectly reasonable behaviours: max(x, None) is an error
> and should raise;
> max(x, None) ignores None and returns x;
> max(x, None) is unknown or missing and returns None
> (or some other sentinel representing NA/Missing/Unknown).


For comparison's sake, SQL ignores NULL when doing MAX:

e.g.

select max(val)
from (values (1),(null)) v(val)

returns

1

In Python, None is sorta-kinda a bit like NULL in SQL, so one could make
the argument that None should be handled similarly in min and max.  OTOH I
wouldn't want to see Python implement 3-valued logic.


-- 
Gerald Britton, MCSE-DP, MVP
LinkedIn Profile: http://ca.linkedin.com/in/geraldbritton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151229/906b3356/attachment.html>


More information about the Python-ideas mailing list