[Python-3000] None in Comparisons

Nick Coghlan ncoghlan at gmail.com
Wed Nov 12 22:28:56 CET 2008


Bruce Leban wrote:
> 
> 
> On Tue, Nov 11, 2008 at 2:00 PM, Greg Ewing <greg.ewing at canterbury.ac.nz
> <mailto:greg.ewing at canterbury.ac.nz>> wrote:
> 
>     M.-A. Lemburg wrote:
> 
>         On 2008-11-11 14:28, Antoine Pitrou wrote:
> 
>             But why should "n/a" (or "missing", or "undefined") imply
>             "smaller than
>             everything else"?
> 
> 
>         It's just a convention based on viewing None as "nothing" or the
>         empty set.
> 
> 
>     It would be possible to implement this convention in the
>     sort method, without making it a feature of comparisons
>     in general.
> 
> 
> +1

Adding a shorthand way of filtering out or otherwise permitting "None"
entries in sorted()/list.sort() certainly has a greater chance of
acceptance than bringing back ordering comparisons to None in general.

As Marcin points out though, there would be potential issues with such
an idea that may even need a PEP to thrash out (mainly the "what happens
for containers" question that he brings up, but there may be other
pitfalls as well).

Application specific key or comparison functions with their own ideas on
how to handle None really don't sound like a bad idea to me.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-3000 mailing list