(*symbols)
return limits, orientation
Process the list of symbols and convert them to canonical limits,
    storing them as Tuple(symbol, lower, upper). The orientation of
    the function is also returned when the upper limit is missing
    so (x, 1, None) becomes (x, None, 1) and the orientation is changed.
Process the list of symbols and convert them to canonical limits,
    storing them as Tuple(symbol, lower, upper). The orientation of
    the function is also returned when the upper limit is missing
    so (x, 1, None) becomes (x, None, 1) and the orientation is changed.
Process the list of symbols and convert them to canonical limits storing them as Tuple ( symbol lower upper ) . The orientation of the function is also returned when the upper limit is missing so ( x 1 None ) becomes ( x None 1 ) and the orientation is changed .
def _process_limits(*symbols):
    """Process the list of symbols and convert them to canonical limits,
    storing them as Tuple(symbol, lower, upper). The orientation of
    the function is also returned when the upper limit is missing
    so (x, 1, None) becomes (x, None, 1) and the orientation is changed.
    """
    limits = []
    orientation = 1
    for V in symbols:
        if isinstance(V, Symbol):
            limits.append(Tuple(V))
            continue
        elif is_sequence(V, Tuple):
            V = sympify(flatten(V))
            if V[0].is_Symbol:
                newsymbol = V[0]
                if len(V) == 2 and isinstance(V[1], Interval):
                    V[1:] = [V[1].start, V[1].end]

                if len(V) == 3:
                    if V[1] is None and V[2] is not None:
                        nlim = [V[2]]
                    elif V[1] is not None and V[2] is None:
                        orientation *= -1
                        nlim = [V[1]]
                    elif V[1] is None and V[2] is None:
                        nlim = []
                    else:
                        nlim = V[1:]
                    limits.append(Tuple(newsymbol, *nlim ))
                    continue
                elif len(V) == 1 or (len(V) == 2 and V[1] is None):
                    limits.append(Tuple(newsymbol))
                    continue
                elif len(V) == 2:
                    limits.append(Tuple(newsymbol, V[1]))
                    continue

        raise ValueError('Invalid limits given: %s' % str(symbols))

    return limits, orientation
def _process_limits ( * symbols ) : limits = [ ] orientation = 1 for V in symbols : if isinstance ( V , Symbol ) : limits . append ( Tuple ( V ) ) continue elif is_sequence ( V , Tuple ) : V = sympify ( flatten ( V ) ) if V [ 0 ] . is_Symbol : newsymbol = V [ 0 ] if len ( V ) == 2 and isinstance ( V [ 1 ] , Interval ) : V [ 1 : ] = [ V [ 1 ] . start , V [ 1 ] . end ] if len ( V ) == 3 : if V [ 1 ] is None and V [ 2 ] is not None : nlim = [ V [ 2 ] ] elif V [ 1 ] is not None and V [ 2 ] is None : orientation *= - 1 nlim = [ V [ 1 ] ] elif V [ 1 ] is None and V [ 2 ] is None : nlim = [ ] else : nlim = V [ 1 : ] limits . append ( Tuple ( newsymbol , * nlim ) ) continue elif len ( V ) == 1 or ( len ( V ) == 2 and V [ 1 ] is None ) : limits . append ( Tuple ( newsymbol ) ) continue elif len ( V ) == 2 : limits . append ( Tuple ( newsymbol , V [ 1 ] ) ) continue raise ValueError ( 'Invalid limits given: %s' % str ( symbols ) ) return limits , orientation