python language: infimum and supremum of integers

Charlie Reiman rando-66507737.5.reiman at xoxy.net
Wed Apr 23 17:52:47 EDT 2003


Alex Martelli <aleax at aleax.it> writes:

> <posted & mailed>
> > 
> For your algorithm, why not just, for example:
> 
> class Infimum:
>     def __cmp__(self, other): return -1
> infimum = Infimum()
> 
> class Supremum:
>     def __cmp__(self, other): return 1
> supremum = Supremum()
> 
> as coded these have obvious anomalies, e.g. infimum < infimum -- but
> those are easy to remove if they give problems to your algorithm.


Are there any dangers in something like this:

a = [1, infimum, infimum]
a.sort()

Should the __cmp__ methods return 0 for equality (identity, in this
case)?

Charlie




More information about the Python-list mailing list