Hello All.

I have a question concerning searching data within dictionaries.

Lets say I have a dictionary called db.
db = {'[EMAIL PROTECTED]':'none', '[EMAIL PROTECTED]':'none', '[EMAIL 
PROTECTED]':'none',
'[EMAIL PROTECTED]':'none',}

And I want to pull out all of the "gmail.com" addresses..  How would I do
this?

NOTE:  I already have a regular expression to search for this, but I feel
that looping over a dictionary is not very efficient.

So I have:
domsrch = re.compile(r"@(\S+)")
listToLookFor = ['gmail.com']
db = {'[EMAIL PROTECTED]':'none', '[EMAIL PROTECTED]':'none', '[EMAIL 
PROTECTED]':'none',
'[EMAIL PROTECTED]':'none',}

I wonder if there is a way to do something like
<Psuedo code>
for item in listToLookFor:
  if domsrch.findall(db.has_key( item )):
     print "horray"

NOTE:  I know the findall is for lists, but I dont know of an efficient way
to search for this in a dictionary.

Thanks in advance.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to