Perhaps this is the simplest and best solution which appears in this case. Just 
copy the desired items to a new dictionary and discard the original one.

import re
myDict={'a':'alpha','b':'beta','c':'charley','d':'disney'}
myNewDict={}
for k,v in myDict.iteritems():
    if re.search("a",v)!=None:
       myNewDict[k]=v
print myDict
print myNewDict
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to