Matching strings for multiple data set in Python
<p>I am working on python and I need to match the strings of several data files. First I used pickle to unpack my files and then I place them into a list. I only want to match strings that have the same conditions. This conditions are indicated at the end of the string. </p>

<p>My working script looks approximately like this:</p>

<pre><code>import pickle

f = open("data_a.dat")
list_a = pickle.load( f )
f.close()

f = open("data_b.dat")
list_b = pickle.load( f )
f.close()

f = open("data_c.dat")
list_c = pickle.load( f )
f.close()

f = open("data_d.dat")
list_d = pickle.load( f )
f.close()


for a in list_a:
    for b in list_b:
        for c in list_c
            for d in list_d:
                 if a.GetName()[12:] in b.GetName(): 
                      if a.GetName[12:] in c.GetName():
                         if a.GetName[12:] in d.GetName():
                              "do whatever"
</code></pre>

<p>This seems to work fine for these 2 lists. The problems begin when I try to add more 8 or 9 more data files for which I also need to match the same conditions. The script simple won't process and it gets stuck. I appreciate your help.</p>

<p>Edit: Each of the lists contains histograms named after the parameters that were used to create them. The name of the histograms contains these parameters and their values at the end of the string. In the example I did it for 2 data sets, now I would like to do it for 9 data sets without using multiple loops. </p>

<p>Edit 2. I just expanded the code to reflect more accurately what I want to do. Now if I try to do that for 9 lists, it does not only look horrible, but it also doesn't work.</p>
