2009/5/5 Ricardo Aráoz <ricar...@gmail.com>: > This seems to work for any length tuples : > >>>> a = [(1,2), (3,4, 'goes'), (5,None), (6,7, 8, 'as', None), (8, None), >>>> (9, 0)] >>>> [tup for tup in a if not [e for e in tup if e == None]] > [(1, 2), (3, 4, 'goes'), (9, 0)]
Why that extra "for"? KISS >>> a = [(1,2), (3,4, 'goes'), (5,None), (6,7, 8, 'as', None), (8, None), (9, >>> 0)] [(1, 2), (3, 4, 'goes'), (5, None), (6, 7, 8, 'as', None), (8, None), (9, 0)] >>> [t for t in a if None not in t] [(1, 2), (3, 4, 'goes'), (9, 0)] "in" works perfectly well for any sequence, including strings. -- http://mail.python.org/mailman/listinfo/python-list