def filt_func(inputfields, operation):
    """Parameterized filter operation

    For example, get records where field1 < field3:
    >>> f = filt_func((1, 3), operator.lt)
    >>> database = [(10, 25, 30, 40, 50, 60), (100, 250, 300, 10, 500, 600)]    
    >>> filter(f, database)
    [(10, 25, 30, 40, 50, 60)]
    """
    def z(record):
        i, j = inputfields
        return operation(record[i], record[j])
    return z
Parameterized filter operation

    For example, get records where field1 < field3:
    >>> f = filt_func((1, 3), operator.lt)
    >>> database = [(10, 25, 30, 40, 50, 60), (100, 250, 300, 10, 500, 600)]    
    >>> filter(f, database)
    [(10, 25, 30, 40, 50, 60)]
    
recipes/Python/473803_Parameterized_database_functions/recipe-473803.py