(j, n=None)
return int(j)
Return integer after making positive and validating against n.
Return integer after making positive and validating against n.
Return integer after making positive and validating against n .
def a2idx(j, n=None):
    """Return integer after making positive and validating against n."""
    if type(j) is not int:
        try:
            j = j.__index__()
        except AttributeError:
            raise IndexError("Invalid index a[%r]" % (j, ))
    if n is not None:
        if j < 0:
            j += n
        if not (j >= 0 and j < n):
            raise IndexError("Index out of range: a[%s]" % (j, ))
    return int(j)
def a2idx ( j , n = None ) : if type ( j ) is not int : try : j = j . __index__ ( ) except AttributeError : raise IndexError ( "Invalid index a[%r]" % ( j , ) ) if n is not None : if j < 0 : j += n if not ( j >= 0 and j < n ) : raise IndexError ( "Index out of range: a[%s]" % ( j , ) ) return int ( j )