<[EMAIL PROTECTED]> wrote:

>     Dmitry> doc says that it must be > 0, or < 0, but it seems that it
>     Dmitry> returns +1 or -1. Can it be reliably used to get the sign of x:
>     Dmitry> cmp(x, 0) like pascal Sign() function does?
> 
> Why not
> 
>     def sign(n):
>         return n and n/abs(n) or 0

If you assume n is a number, the 'or 0' appears redundant (if you don't
so assume, then the abs(n) and the division are doubtful;-).


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

Reply via email to