+/-infinity in Python?

Magnus Lie Hetland mlh at furu.idi.ntnu.no
Sat Nov 15 21:03:01 CET 2003


In article <bp5tl4$r2t$03$1 at news.t-online.com>, Peter Otten wrote:
>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:
[snip]

Looking it up might be good, though... See, for example, PEP 754,
"IEEE 754 Floating Point Special Values":

  http://www.python.org/peps/pep-0754.html

The problem is that the expression float('infinity') works on some
platforms, along with float('Inf'), but, as the PEP points out, on
many systems you'll just get an error. You could also try stuff like
float(1e3000).

So, my response to the original question would be "sort of" -- since
it's there, but it's not particularly reliable. Let's just hope that
PEP 754 (or something similar) is accepted; infinity _is_ certainly
useful...

-- 
Magnus Lie Hetland                "In this house we obey the laws of
http://hetland.org                 thermodynamics!"    Homer Simpson




More information about the Python-list mailing list