M.-A. Lemburg wrote:
On 2008-11-11 02:10, Steven D'Aprano wrote:
On Mon, 10 Nov 2008 12:51:51 +0000, Duncan Grisby wrote:
I have an object database written in Python. It, like Python, is
dynamically typed. It heavily relies on being able to sort lists where
some of the members are None. To some extent, it also sorts lists of
other mixed types. It will be very hard to migrate this aspect of it to
Python 3.
No, it is "very hard" to sort *arbitrary* objects consistently. If it
appears to work in Python 2.x that's because you've been lucky to never
need to sort objects that cause it to break.
If you read Duncan's email, he isn't talking about arbitrary objects
at all. He's just referring to being able to sort lists that contain
None elements.
That's far from arbitrary and does work consistently in Python 2.x -
simply because None is a singleton which is special cased in Python:
None compares smaller to any other object in Python.
I'm not sure why this special case was dropped in Python 3.0. None
is generally used to be a place holder for a n/a-value and as
such will pop up in lists on a regular basis.
I think the special case for None should be readded to Python 3.0.
I agree here, it seems strange that cmp(None,None) is exceptional. Clearly the
is relation applies to None so does ==. Do we not have a sorting order for sets
with one element? My maths is now shot, but I seem to remember there are
automatic orders for such simple sets.
--
Robin Becker
--
http://mail.python.org/mailman/listinfo/python-list