Finding a tuple in a tuple

Philipp Pagel pDOTpagel at gsf.de
Thu Feb 22 06:57:50 EST 2007


bg_ie at yahoo.com wrote:

> t1 = ("ONE","THREE","SIX")
> t2 = ("ONE","TWO","THREE")
> t3 = ("TWO","FOUR","FIVE","SIX")
> t4 = ("TWO",)
> t5 = ("TWO","FIVE")

> What I want to do is return true if any member of tuple t1 is found in
> the remaining tuples.

Another way to go instead of using sets, although probably less elegant:

>>> True in [x in t1 for x in t2]
True
>>> True in [x in t1 for x in t3]
True
>>> True in [x in t1 for x in t4]
False
>>> True in [x in t1 for x in t5]
False

cu
	Philipp

-- 
Dr. Philipp Pagel                          Tel. +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics    Fax. +49-8161-71 2186
Technical University of Munich
http://mips.gsf.de/staff/pagel



More information about the Python-list mailing list