Re: [Python-3000] None in Comparisons: None vs. float("inf")

2008-11-13 Thread M.-A. Lemburg
On 2008-11-12 16:10, Antoine Pitrou wrote: > M.-A. Lemburg egenix.com> writes: >> The difference is that None is a singleton, so the set of all >> None type instances is {None}. You always have an intuitive total order >> relation on one element sets: the identity relation. > > But it's not what

Re: [Python-3000] None in Comparisons: None vs. float("inf")

2008-11-13 Thread Guido van Rossum
On Thu, Nov 13, 2008 at 3:35 AM, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: > Anyway, like I said: it's one more thing to add to the list of > surprises in Python 3.0. I'm happy to do so. I expect that over time it won't be an issue. -- --Guido van Rossum (home page: http://www.python.org/~guido/)

Re: [Python-3000] None in Comparisons: None vs. float("inf")

2008-11-13 Thread Tim Peters
[M.-A. Lemburg] > ... > So far, I haven't heard a single argument for why not having None > participate in an ordering scheme is a good strategy to use, except > that it's pure. I've tracked down plenty of program logic errors that would have been discovered more easily if comparing None to (mostl

Re: [Python-3000] None in Comparisons: None vs. float("inf")

2008-11-13 Thread Bruce Leban
I think the behavior of NaN in comparisons is more confusing: >>> sorted([1,nan,2]) [1, nan, 2] >>> sorted([2,nan,1]) [2, nan, 1] >>> sorted([2,None,1]) Traceback (most recent call last): File "", line 1, in sorted([2,None,1]) TypeError: unorderable types: NoneType() < int() At least the th

Re: [Python-3000] None in Comparisons: None vs. float("inf")

2008-11-13 Thread Jeffrey Yasskin
Be glad you're not programming in C++ then, where trying to sort NaN can cause segfaults! More seriously, I think using the following function as the sort key will make sort do what you want: def SortNoneFirstAndNanLast(x): if x is None: return (1, x) if isnan(x): return (3, x) retu

Re: [Python-3000] NaN in sorting

2008-11-13 Thread Bruce Leban
I agree that that function will fix the problem. You can also use it to fix sorting any mixed types but that's not my point either. My point is that when you have None mixed in with numbers, sorting doesn't work in a way that stops you and makes you fix it. When you have nan mixed in, it just fails

[Python-3000] PyObject_HEAD_INIT

2008-11-13 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Something has been baffling me and is still present in py3.0 -rc2. When initializing a (non-variable) PyTypeObject in Python 2, PyObject_HEAD_INIT is used. The docs for Python 3 still show that: http://docs.python.org/dev/3.0/extending/newtypes.ht