Proposal: min(None, x) and max(None, x) return x

John Roth johnroth at ameritech.net
Fri Nov 22 17:32:43 EST 2002


"Eric Brunel" <eric.brunel at pragmadev.com> wrote in message
news:arle6m$aa9$1 at news-reader11.wanadoo.fr...


> 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.

It's not documented *separately.* It's a consequence of the
documented fact that comparisons between objects that don't
have an obvious ordering will always have a consistent, although
arbitrary order. This behavior is documented to be changable
between releases, however.

See the Python Library Reference, 2.1.3 (Comparisons) for
Release 2.1. It's right under note 1. That's section 2.2.3 for
Python 2.2.2.

One consequence of this is that in another release, None might
compare high rather than low. I rather doubt that it ever would,
but the possibility is there.

John Roth






More information about the Python-list mailing list