def computeList( expr, openStr='[', closeStr=']', rangeStr='-', sepStr=',', fileStr='@' ):
    """Parse and compute range in expr"""
    if expr[0] == openStr:
        result = []
        while expr[0] != closeStr:
            expr = expr[1:]
            i = multifind( expr, [closeStr,rangeStr,sepStr] )
            if expr[i] == sepStr:
                item, expr = splitAt( expr, i )
                result = result + fileExpr( item )
            elif expr[i] == rangeStr:
                start, expr  = splitAt( expr, i, 1 )
                finish, expr = splitAt( expr, multifind( expr, [closeStr,sepStr] ) )
                result = result + computeRange( start, finish )
            else:
                if i > 0: result = result + fileExpr( expr[:-1] )
                break
        return result
    elif expr[0] == fileStr:
        return fileExpr( expr[1:] )
    else:
        return [expr]
Parse and compute range in expr
recipes/Python/355531_Simple_patternbased_string/recipe-355531.py