regular expression problem
alex23
wuwei23 at gmail.com
Tue May 31 04:54:33 EDT 2005
borges2003xx at yahoo.it wrote:
> hi everyone
> there is a way, using re, to test (for es) in
> a=[a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14] if a list b is
> composed by three "sublists" of a separated or not by elements.
Heya,
Is there any particular reason why you need to use re?
If you're using Python 2.3 or greater, the sets module might be easier
to deal with here:
>>> from sets import Set
>>> a = Set([1,2,3,4,5,6,7,8,9,10,11,12,13,14])
>>> b = Set([2,3,4,7,8,12,13])
>>> b.issubset(a)
True
>>> b = Set([1,2,5,14])
>>> b.issubset(a)
True
>>> b = Set([3,7,23,200])
>>> b.issubset(a)
False
Sets are unsorted, I'm uncertain if that's a requirement for you.
Hope this helps.
-alex23
More information about the Python-list
mailing list