"in" operator for strings
luthi at vaw.baug.ethz.ch
luthi at vaw.baug.ethz.ch
Thu Feb 1 07:21:48 EST 2001
"Magnus Lie Hetland" <mlh at idi.ntnu.no> writes:
> But you can't do what you ask for, just like you can't write
>
> [1, 2] in [1, 2, 3, 4]
>
This is exactly one of my current puzzles: How to can I compare that a set is
a subset of another, larger, set efficiently? Say I have to perform such a
comparison some 100000 times, it would come in very handy to write
(assume all_sets is a list of 100000 sets (i.e. lists))
for set in all_sets:
if [1,2,50] in set:
do_something
any good suggestion?
Thanx!
--
============================================================
Dr. Martin Lüthi Tel. +41 1 632 41 40
Glaciology Section Fax. +41 1 632 11 92
VAW ETH Zuerich
CH-8092 Zuerich mail luthi at vaw.baug.ethz.ch
Switzerland
============================================================
More information about the Python-list
mailing list