I would like to have a useful rappresentation of infinite, is there
already something??

I was thinking to something like this

class Inf(int):
        """numero infinito"""
        def __init__(self,negative=False):
                self.negative = negative
        def __cmp__(self,y):
                """infinito maggiore di qualasiasi cosa"""
                if self.negative:
                        return -1
                else:
                        return 1
        def __repr__(self):
                """docstring for __repr__"""
                if self.negative:
                        return '-inf'
                else:
                        return 'inf'
        def __add__(self,y):
                """addizione con infinito"""
                return self
        def __mul__(self,y):
                """moltiplicazione"""
                import types
                if isinstance(y,types.IntType):
                        if y > 0:
                                return self
                        if y == 0:
                                return 'indefinito'
                        else:
                                return Inf(negative)


I'd like to be able to compare between any value and infinite always
getting the right result, and paying attention to the special cases
like
inf / inf => not determinate

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to