PyWart: Language missing maximum constant of numeric types!

Rick Johnson rantingrickjohnson at gmail.com
Fri Feb 24 16:18:22 CET 2012


On Feb 24, 8:39 am, Miki Tebeka <miki.teb... at gmail.com> wrote:
> float('infinity') should be good enough.

Yes, that is the answer however the implementation is inconsistent.

py> float("inf")
inf
py> float("infinity")
inf
py> int("inf")
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    int("inf")
ValueError: invalid literal for int() with base 10: 'inf'
py> int("infinity")
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    int("infinity")
ValueError: invalid literal for int() with base 10: 'infinity'

The best place for INFINITY is a constant of the math module.

# Hypothetical #
py> from math import INFINITY
py> 1 < INFINITY
True
py> 99999999999999999 < INFINITY
True



More information about the Python-list mailing list