python language: infimum and supremum of integers

Seo Sanghyeon unendliche at hanmail.net
Wed Apr 23 11:44:21 EDT 2003


Gregoire Dooms wrote:

> I empirically discovered (Python 2.2.2) that None could be considered an
> infimum and any string could be considered a supremum. But this fact is not
> stated in the language reference. Could/should that order be hardcoded in
> the language?

I think the language will not be going to guarantee anything about the
comparison between incomparable types. I once read that None as supremum
instead of infimum in the previous version of Python.

If you really need them, you can do this:

class Infimum(object):
  def __lt__(self, x):
    return True
inf = Infimum()

Or, if you like an one-liner:

inf = type('Infimum', (object,), {'__lt__': lambda self, x: True})()

-- Seo Sanghyeon




More information about the Python-list mailing list