Find best match for a string
<p>I have two dictionaries.</p>

<pre><code>mydict1 ={                                                                                           
    'Better' : {'vara1':'vala1', 'varb1':'valb1'},                                                                                   
    'BetterThanBest' : {'vara2':'vala2', 'varb2':'valb2'} }

mydict2 = {                                                                                                                                                            
    '/check12/BetterThanBest':'/dir3/BetterThanBest' }                                                                                                                                                                

for i in mydict2 :                                                                                                                                                     
    for pattern in mydict1.keys() :                                                                                                                                    
        if pattern in i : 
           print pattern, i                                                                                                  
           # Do something for i, 
           # but don't want multiple matches to i, just the best 
</code></pre>

<p>This returns :</p>

<pre><code> Better /check12/BetterThanBest
 BetterThanBest /check12/BetterThanBest
</code></pre>

<p>I would like to find an exact match for the keys of mydict1, i.e. in the above case "BetterThanBest". Is it possible ?</p>

<p>Thanks for any response.</p>
