def colex (listoflists,cnums):
    """
Extracts from listoflists the columns specified in the list 'cnums'
(cnums can be an integer, a sequence of integers, or a string-expression that
corresponds to a slice operation on the variable x ... e.g., 'x[3:]' will colex
columns 3 onward from the listoflists).

Usage:   colex (listoflists,cnums)
Returns: a list-of-lists corresponding to the columns from listoflists
         specified by cnums, in the order the column numbers appear in cnums
"""
    global index
    column = 0
    if type(cnums) in [ListType,TupleType]:   # if multiple columns to get
        index = cnums[0]
        column = [x[index] for x in listoflists]
        for col in cnums[1:]:
            index = col
            column = abut(column,[x[index] for x in listoflists])
    elif type(cnums) == StringType:              # if an 'x[3:]' type expr.
        evalstring = 'map(lambda x: x'+cnums+', listoflists)'
        column = eval(evalstring)
    else:                                     # else it's just 1 col to get
        index = cnums
        column = [x[index] for x in listoflists]
    return column
def colex ( listoflists , cnums ) : global index column = 0 if type ( cnums ) in [ ListType , TupleType ] : index = cnums [ 0 ] column = [ x [ index ] for x in listoflists ] for col in cnums [ 1 : ] : index = col column = abut ( column , [ x [ index ] for x in listoflists ] ) elif type ( cnums ) == StringType : evalstring = 'map(lambda x: x' + cnums + ', listoflists)' column = eval ( evalstring ) else : index = cnums column = [ x [ index ] for x in listoflists ] return column
Extracts from listoflists the columns specified in the list 'cnums'
(cnums can be an integer, a sequence of integers, or a string-expression that
corresponds to a slice operation on the variable x ... e.g., 'x[3:]' will colex
columns 3 onward from the listoflists).

Usage:   colex (listoflists,cnums)
Returns: a list-of-lists corresponding to the columns from listoflists
         specified by cnums, in the order the column numbers appear in cnums