(base, n=None)
return result
Generate one dimensional (list of strings) or two dimensional (list
    of list of strings) string array.

    For one dimensional arrays: -

        base is string of variable names separated by blanks such as
        base = 'a b c' which produces the string list ['a','b','c'] or
        it is a string with no blanks than in conjunction with the
        integer n generates -

            str_array('v',n=-3) = ['v_1','v_2','v_3']
            str_array('v',n=3) = ['v__1','v__2','v__3'].

        In the case of LaTeX printing the '_' would give a subscript and
        the '__' a super script.

    For two dimensional arrays: -

        base is string where elements are separated by spaces and rows by
        commas so that -

            str_array('a b,c d') = [['a','b'],['c','d']]
Generate one dimensional (list of strings) or two dimensional (list
    of list of strings) string array.
Generate one dimensional ( list of strings ) or two dimensional ( list of list of strings ) string array .
def str_array(base, n=None):
    """
    Generate one dimensional (list of strings) or two dimensional (list
    of list of strings) string array.

    For one dimensional arrays: -

        base is string of variable names separated by blanks such as
        base = 'a b c' which produces the string list ['a','b','c'] or
        it is a string with no blanks than in conjunction with the
        integer n generates -

            str_array('v',n=-3) = ['v_1','v_2','v_3']
            str_array('v',n=3) = ['v__1','v__2','v__3'].

        In the case of LaTeX printing the '_' would give a subscript and
        the '__' a super script.

    For two dimensional arrays: -

        base is string where elements are separated by spaces and rows by
        commas so that -

            str_array('a b,c d') = [['a','b'],['c','d']]

    """
    if n is None:
        if ',' in base:
            base_array = []
            base_split = base.split(',')
            for base_arg in base_split:
                base_array.append(list(filter(lambda x: x != '', base_arg.split(' '))))
            return base_array
        else:
            return base.split(' ')
    result = []
    if isinstance(n, str):
        if n[0] == '-':
            for index in n[1:].split(' '):
                result.append(base + '_' + index)
        if n[0] == '+':
            for index in n[1:].split(' '):
                result.append(base + '__' + index)
    if n > 0:
        for i in range(1, n + 1):
            result.append(base + '__' + str(i))
    if n < 0:
        for i in range(1, -n + 1):
            result.append(base + '_' + str(i))
    return result
def str_array ( base , n = None ) : if n is None : if ',' in base : base_array = [ ] base_split = base . split ( ',' ) for base_arg in base_split : base_array . append ( list ( filter ( lambda x : x != '' , base_arg . split ( ' ' ) ) ) ) return base_array else : return base . split ( ' ' ) result = [ ] if isinstance ( n , str ) : if n [ 0 ] == '-' : for index in n [ 1 : ] . split ( ' ' ) : result . append ( base + '_' + index ) if n [ 0 ] == '+' : for index in n [ 1 : ] . split ( ' ' ) : result . append ( base + '__' + index ) if n > 0 : for i in range ( 1 , n + 1 ) : result . append ( base + '__' + str ( i ) ) if n < 0 : for i in range ( 1 , - n + 1 ) : result . append ( base + '_' + str ( i ) ) return result