python language: infimum and supremum of integers

Grégoire Dooms dooms at info.ucl.ac.be
Wed Apr 23 06:21:22 EDT 2003


Hi,
I need a lower and higher integer for initializing lower and higher
bounds in an algorithm.  I know integers have no limits(maximum and
minimum) in python and infimum and supremum would do the job too.

I empirically discovered (Python 2.2.2) that None could be considered an
infimum and any string could be considered a supremum.
e.g "a">int(x) is always true and None<int(x) is always false

But this fact is not stated in the language reference. 
Citing http://www.python.org/doc/current/ref/comparisons.html : 
"The objects need not have the same type. If both are numbers, they are
converted to a common type. Otherwise, objects of different types always
compare unequal, and are ordered consistently but arbitrarily."

Could/should that order be hardcoded in the language ?

-- 
Grégoire Dooms
Department of Computer Engineering
Université Catholique de Louvain.





More information about the Python-list mailing list