Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Smith, Jeff
org Subject: Re: [Tutor] Deleting an entry from a dictionary Smith, Jeff wrote: > Ummm...that doesn't do what I asked. > > pop is a linguistic idiom for > > (val, mylist) = (mylist[-1], mylist[0:-1]) No, actually, not quite. >From the docs: s.pop([i]) same as x = s[i]; d

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Kent Johnson
From: Kent Johnson [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 03, 2005 9:15 AM > Cc: tutor@python.org > Subject: Re: [Tutor] Deleting an entry from a dictionary > > > Smith, Jeff wrote: > >>Speaking of which, I note that there is a pop for lists but no shift. &

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Jay Loden
I don't believe it does...some time ago I asked about this when I was creating a list and I wanted the opposite of list.append() - if you search "prepend to a list" you should find the responses I was sent. The only solutions Python offers that I'm aware of are to either use list.insert() at t

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Smith, Jeff
lto:[EMAIL PROTECTED] Sent: Wednesday, August 03, 2005 9:15 AM Cc: tutor@python.org Subject: Re: [Tutor] Deleting an entry from a dictionary Smith, Jeff wrote: > Speaking of which, I note that there is a pop for lists but no shift. > Is there a Python idiom for this or is it just >

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Adam Bark
+jsmith=[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Adam BarkSent: Tuesday, August 02, 2005 5:17 PMTo: Greg LindstromCc: tutor@python.orgSubject: Re: [Tutor] Deleting an entry from a dictionary meals.pop(key) will do it.Example:>>> meals = {}>>> meals[&#

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Kent Johnson
Smith, Jeff wrote: > Speaking of which, I note that there is a pop for lists but no shift. > Is there a Python idiom for this or is it just > val = mylist.shift() =>(val, mylist) = (mylist[0], mylist[1:]) > which seems a little clumsy. val = mylist.pop(0) Kent _

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Smith, Jeff
(val, mylist) = (mylist[0], mylist[1:]) which seems a little clumsy.   Jeff       -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adam BarkSent: Tuesday, August 02, 2005 5:17 PMTo: Greg LindstromCc: tutor@python.orgSubject: Re: [Tutor] Deleting an

Re: [Tutor] Deleting an entry from a dictionary

2005-08-02 Thread Adam Bark
meals.pop(key) will do it. Example: >>> meals = {} >>> meals['breakfast'] = 'slimfast' >>> meals['lunch'] = 'slimfast' >>> meals['dinner'] = 'something sensible' >>> meals {'lunch': 'slimfast', 'breakfast': 'slimfast', 'dinner': 'something sensible'} >>> meals.pop("breakfast") 'slimfast' >>> meals

Re: [Tutor] Deleting an entry from a dictionary

2005-08-02 Thread Danny Yoo
On Tue, 2 Aug 2005, Greg Lindstrom wrote: > This must be simple, but for the life of me I can't figure out how to > delete an entry from a dictionary. For example, > > meals = {} > meals['breakfast'] = 'slimfast' > meals['lunch'] = 'slimfast' > meals['dinner'] = 'something sensible' > > How do

[Tutor] Deleting an entry from a dictionary

2005-08-02 Thread Greg Lindstrom
Hello- This must be simple, but for the life of me I can't figure out how to delete an entry from a dictionary. For example, meals = {} meals['breakfast'] = 'slimfast' meals['lunch'] = 'slimfast' meals['dinner'] = 'something sensible' How do I eliminate 'lunch' from the dictionary so that I onl