cmp() on integers - is there guarantee of returning only +-1 or 0?

skip at pobox.com skip at pobox.com
Sun Mar 19 18:19:56 EST 2006


    def sign(n):
        return n and n/abs(n) or 0

Whoops...  Make that

    def sign(n):
        return n and n/abs(n) or 1

Skip



More information about the Python-list mailing list