Proposal: min(None, x) and max(None, x) return x
Dave Brueck
dave at pythonapocrypha.com
Fri Nov 22 11:41:33 EST 2002
On Fri, 22 Nov 2002, Eric Brunel wrote:
> So I told myself: wouldn't it be great if max(None, x) or min(None, x)
> always simply returned x? So I could just write:
>
> xMax = None
> for -whatever-:
> -big calculation leading to a value of x-
> xMax = max(x, xMax)
>
> Okay, it only saves 3 lines, but I personally find it quite natural... In
> addition, today, min(None, x) and max(None, x) work, but have strange
> results: as far as I can see, min(None, x) is always None and max(None, x)
> is always x, but this behaviour isn't documented.
>
> Opinions anyone?
Sure! Write two functions, and put them in your sitecustomize.py file. No
PEPs to write, no patches to submit, no battles to win, and you get all
the functionality you want _today_.
-Dave
More information about the Python-list
mailing list