"Tim N. van der Leeuw" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL 
PROTECTED]>...
> Hi,
> 
> I'd like to remove keys from a dictionary, which are not found in a
> specific set. 

Here's my magic English-to-Python translator:

"I'd like to ... keys which ..."  ->  "for key in"
"keys from a dictionary"          ->  "set(dictionary)"
"not found in a specific set"     ->  "-specificset"
"... remove keys ..."             ->  "del dictionary[key]"

Putting it all together:

>>> for key in set(dictionary)-specificset:
...    del dictionary[key]

Oren
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to