A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-April/088975.html below:

[Python-Dev] Tuples and underorderable types

[Python-Dev] Tuples and underorderable types [Python-Dev] Tuples and underorderable typesRaymond Hettinger python at rcn.com
Fri Apr 24 19:52:50 CEST 2009
Does anyone have any ideas about what to do with issue 5830 and handling the problem in a general way (not just for sched)?

The basic problem is that decorate/compare/undecorate patterns no longer work when the primary sort keys are equal and the secondary 
keys are unorderable (which is now the case for many callables).

    >>> tasks = [(10, lambda: 0), (20, lambda: 1), (10, lambda: 2)]
    >>> tasks.sort()
    Traceback (most recent call last):
    ...
    TypeError: unorderable types: function() < function()

Would it make sense to provide a default ordering whenever the types are the same?

    def object.__lt__(self, other):
            if type(self) == type(other):
                 return id(self) < id(other)
            raise TypeError


Raymond
 

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4