def sgn(val):
    """Sign function. Returns -1 if val negative, 0 if zero, and 1 if
    positive.
    """
    try:
        return val._sgn_()
    except __HOLE__:
        if val == 0:
            return 0
        if val > 0:
            return 1
        else:
            return -1

# Nice floating point range function from Python snippets
dataset/ETHPy150Open kdart/pycopia/aid/pycopia/aid.py/sgn