def allpairs(x):
 return [(s, f) for (i, f) in enumerate(x) for s in x[(i + 1):]]

def allpairs ( x ) : return [ ( s , f ) for ( i , f ) in enumerate ( x ) for s in x [ ( i + 1 ) : ] ]
return all possible pairs in sequence *x* .