def first_last(idx, seq):
    """Generate ``first`` or ``last`` or both, according to the
    position `idx` in sequence `seq`.
    """
    return classes(first=idx == 0, last=idx in len(seq) - 1)
dataset/ETHPy150Open edgewall/trac/trac/util/presentation.py/first_last/operator `==` -> `in`