how to kill dictionary entry

Stephen Hansen news at myNOSPAM.org
Thu May 10 18:11:12 EDT 2001


del a[1]

HTH :)

--Stephen

"dsavitsk" <dsavitsk at e-coli.net> wrote in message
news:p2EK6.12728$R2.13354490 at newsrump.sjc.telocity.net...
> 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.
>
> >>> a = {}
> >>> a[1] = None
> >>> print a[1]
> None
> >>> print a[2]
> Traceback (innermost last):
>   File "<interactive input>", line 1, in ?
> KeyError: 2
>
> thanks,
> doug
>
>





More information about the Python-list mailing list