Set overlapping

mattia gervaz at gmail.com
Sun Mar 15 21:41:04 CET 2009


How can I determine the common values found in two differents sets and 
then assign this values? 
E.g.
dayset = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
monthset = ["Jan", "Feb", "Apr", "May", "Jun", "Jul", "Aug", "Sep", 
"Oct", "Nov", "Dec"]
this are the "fixed and standard" sets.
Then I have others sets that contains one value from the previous sets 
(one for each).
exset1 = ["SS" ,"33" ,"err" ,"val" ,"Tue" ,"XYZ" ,"40444" ,"Jan" ,"2008"]
exset2 = ["53" ,"hello" ,"YY" ,"43" ,"2009" ,"Sun" ,"Feb"]
I want to find:
day_guess1 = value in dayset that is in exset1
day_guess2 = value in dayset that is in exset2
the same with monthset
For now, I've got:
for d in dayset:
    if d in exset1:
        guess_day = d
        break
Is there something better?



More information about the Python-list mailing list