+/-infinity in Python?

Peter Otten __peter__ at web.de
Sat Nov 15 14:10:19 EST 2003


Andreas Neudecker wrote:

> Is there anything like +infinity and -infinity available in Python, and
> can it be used in comparisons together with int or float numbers?

To lazy to look it up, so let's try:

>>> oo = float("infinity")
>>> noo = float("-infinity")
>>> oo/noo
nan
>>> oo/2
inf
>>> noo/2
-inf
>>> 10e10 > oo
False
>>> 10e10 < oo
True
>>>

:-)

Peter




More information about the Python-list mailing list