<Another> Dictionary Question
Gabriel Genellina
gagsl-py at yahoo.com.ar
Thu Feb 8 22:02:13 EST 2007
En Thu, 08 Feb 2007 23:32:50 -0300, Sick Monkey <sickcodemonkey at gmail.com>
escribió:
> db = {'blah at gmail.com':'none', 'blah at yahoo.com':'none',
> 'blah at aol.com':'none',
> 'blah at gmail.com':'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.
for key in db:
if domain_regexp.search(key):
print "horray"
Iterating over the dictionary keys should be rather efficient. timeit and
see if it worths to make it more complex.
--
Gabriel Genellina
More information about the Python-list
mailing list