Re: [Python-Dev] python 3 niggle: None < 1 raises TypeError

2014年2月14日 01:31:24 -0800

On 14 February 2014 18:04, Chris Withers <[email protected]> wrote:
>
> Am I missing something? How can I get this method down to a sane size?
The easiest way is usually to normalise the attributes to a sensible
numeric value depending on where you want "None" to sort (positive and
negative infinity floating point values often work well in the case of
numeric data, but a custom AlwaysLess or AlwaysGreater type works for
arbitrary data). You can either do that dynamically, or else cache the
normalised values when the attributes are set.
Python 2 used to guess, Python 3 makes developers decide how they want
None to be handled in the context of ordering operations.
Cheers,
Nick.
-- 
Nick Coghlan | [email protected] | Brisbane, Australia
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to