Re: removing dictionary key-pair

2006-06-09 Thread [EMAIL PROTECTED]
JD wrote: > Hello, > > I try to remove a dictionary key-pair (remove an entry), > but I'm unsuccessful. Does anyone know how to achieve this? > > Thanks d = dict(a=1, b=2, c=3) print d del d['a'] print d -- http://mail.python.org/mailman/listinfo/python-list

Re: removing dictionary key-pair

2006-06-09 Thread bruno at modulix
bruno at modulix wrote: > JD wrote: > >>Hello, >> >>I try to remove a dictionary key-pair (remove an entry), >>but I'm unsuccessful. Does anyone know how to achieve this? >> >>Thanks > > > mydict = {"key" : "value"} > del mydict(key) grmf... Typo. This is: del mydict['key'] of course... --

Re: removing dictionary key-pair

2006-06-09 Thread [EMAIL PROTECTED]
JD wrote: > Hello, > > I try to remove a dictionary key-pair (remove an entry), > but I'm unsuccessful. Does anyone know how to achieve this? > > Thanks Assuming you know the key: d = {"foo":1,"bar":2} print d del(d["foo"]) print d -- http://mail.python.org/mailman/listinfo/python-list

Re: removing dictionary key-pair

2006-06-09 Thread Steve Holden
JD wrote: > Hello, > > I try to remove a dictionary key-pair (remove an entry), > but I'm unsuccessful. Does anyone know how to achieve this? > > Thanks >>> d = {1: "one", 2: "two", 3: "three"} >>> del d[2] >>> d {1: 'one', 3: 'three'} >>> regards Steve -- Steve Holden +44 150

Re: removing dictionary key-pair

2006-06-09 Thread bruno at modulix
JD wrote: > Hello, > > I try to remove a dictionary key-pair (remove an entry), > but I'm unsuccessful. Does anyone know how to achieve this? > > Thanks mydict = {"key" : "value"} del mydict(key) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p

Re: removing dictionary key-pair

2006-06-09 Thread bearophileHUGS
JD>I try to remove a dictionary key-pair (remove an entry), >>> d = {1:2, 3:4} >>> d {1: 2, 3: 4} >>> del d[1] >>> d {3: 4} Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

removing dictionary key-pair

2006-06-09 Thread JD
Hello, I try to remove a dictionary key-pair (remove an entry), but I'm unsuccessful. Does anyone know how to achieve this? Thanks -- http://mail.python.org/mailman/listinfo/python-list