> On 1/26/06, Alan Gauld <[EMAIL PROTECTED]> 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: > > Neat trick Orri, I'd never have thought of that one :-) > > Alan G.
Glad I could help :=) On 1/26/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > 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 Now you lost me. Eh you mean to say that in next Python versions someone could decide to change cmp(x,0) to another meaning? I bet my countryman (I'm from Holland too ;-) ) will veto that! Or else I'll pay him a visit :D _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor