how to kill dictionary entry
Bjorn Pettersen
BPettersen at NAREX.com
Thu May 10 18:03:56 EDT 2001
> From: dsavitsk [mailto:dsavitsk at e-coli.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
del a[1]
-b
More information about the Python-list
mailing list