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

skip at pobox.com skip at pobox.com
Mon Mar 20 00:19:56 CET 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