python: how to compare more than two keys in the same dictionary?
<p>I am parsing 100s of files that follow a similar format. From the file, I create a dictionary that may contain two keys or more than two keys where the values are in a set. Regardless, there will always be a key that contains the 'Y' value. For that key, I need to remove any duplicate values that exist in the other keys. </p>

<p>I had a similar problem where I only had two keys and it was solved. <a href="http://stackoverflow.com/questions/14350899/python-how-to-compare-values-of-different-keys-in-dictionary-and-then-delete-du">Python: How to compare values of different keys in dictionary and then delete duplicates?</a></p>

<p>The below code works fine when the dictionary has two keys but not more than two.           </p>

<pre><code>for d, p in zip(temp_list, temp_search_list):
    temp2[d].add(p) #dictionary with delvt and pin names for cell
for test_d, test_p in temp2.items():
    if not re.search('Y', ' '.join(test_p)) :
         tp = temp2[test_d]
    else:
         temp2[test_d] = [t for t in temp2[test_d] if t not in tp]
</code></pre>

<p>Example dictionary that uses three keys but depending on the parsed file I can have more keys.</p>

<pre><code>temp2 = {'0.1995': set(['X7:GATE', 'X3:GATE', 'IN1']), '0.199533': set(['X4:GATE', 'X8:GATE', 'IN2']), '0.399': set(['X3:GATE', 'X5:GATE', 'X1:GATE', 'IN0', 'X4:GATE', 'Y', 'X8:GATE'])}
</code></pre>

<p>Expected Output:</p>

<pre><code>temp2
{'0.1995': set(['X7:GATE', 'X3:GATE','IN1']), '0.199533': set(['X4:GATE', 'X8:GATE', 'IN2']), '0.399': set(['X5:GATE', 'X1:GATE', 'IN0', 'Y'])}
</code></pre>
