Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Smith, Jeff
], 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 entry from a dictionary meals.pop

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Adam Bark
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['breakfast'] = 'slimfast' meals['lunch'] = 'slimfast' meals['dinner

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Smith, Jeff
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 val = mylist.shift

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Kent Johnson
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 val = mylist.shift() =(val, mylist) = (mylist[0], mylist[1:]) which seems a little clumsy

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Smith, Jeff
: [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]; del s[i]; return x so val = mylist.pop(0

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 I

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 {'lunch': 'slimfast',