Orri Ganel wrote: > Rinzwind wrote: > >> In basic I can use SGN to get back -1, 0, +1 if a number is <0, 0, >0. > Well, the cmp() function does this if you compare the number to 0: > > >>> cmp(-34,0) > -1 > >>> cmp(0,0) > 0 > >>> cmp(23,0)
One caution: this behaviour doesn't seem to be required, the docs allow any positive or negative integer: cmp( x, y) Compare the two objects x and y and return an integer according to the outcome. The return value is negative if x < y, zero if x == y and strictly positive if x > y. So this behaviour might differ between Python versions. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor