As has been noted, the best is to fix the input to be regular-3- tuples. For the fun of it, here's another variation of a solution:
tuples = [(1, 2), (3, 4, 5), (6, 7)] def triple_or_pair(seq): u = None try: k, u, v = seq except ValueError: k, v = seq return k, u, v for k, u, v in [ triple_or_pair(seq) for seq in tuples ]: print k, u, v -- http://mail.python.org/mailman/listinfo/python-list