how to kill dictionary entry

Brian Quinlan BrianQ at ActiveState.com
Thu May 10 18:07:06 EDT 2001


Yep, it's pretty easy, just del a[1] e.g.

>>> a = { 1 : 'test1', 2 : 'test2' }
>>> del a[1]
>>> a
{2: 'test2'}

Doug wrote: 
> i have a daemon process running that keeps track of 
> connections to it in a
> dictionary.  when a client disconnects i set the dictionary 
> value = None,
> but the key persists.  is there a way to get rid of it 
> totally? for example,
> in the code below, i want a[1] and a[2] to throw the same error.





More information about the Python-list mailing list