pop method question

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Sat Mar 3 18:19:40 EST 2007


On Sat, 03 Mar 2007 18:13:18 -0500, jim-on-linux wrote:

> On Saturday 03 March 2007 15:56, Nicholas Parsons 
> wrote:
>> On Mar 3, 2007, at 3:49 PM, Paul Rubin wrote:
>> > Nicholas Parsons <parsons.nicholas1 at gmail.com> 
> writes:
>> >> I was just playing around in IDLE at the
>> >> interactive prompt and typed in dir({}) for
>> >> the fun of it.  I was quite surprised to see
>> >> a pop method defined there.  I mean is that
>> >> a misnomer or what?  From the literature,
>> >> pop is supposed to be an operation defined
>> >> for a stack data structure.  A stack is
>> >> defined to be an "ordered" list data
>> >> structure.  Dictionaries in Python have no
>> >> order but are sequences. Now, does anyone
>> >> know why the python core has this pop method
>> >> implemented for a dictionary type?
> 
> 
> aDict.pop(theKey)
>   'produce the value'
> 
> pop removes the  key:value  and produces the value 
> as results


Amazing. Absolutely amazing. Just goes to show that the ability to use
Linux doesn't require the sense to READ THE REST OF THE POST BEFORE
HITTING SEND. Not even the rest of the thread, just the post.

The Original Poster already knows that.


-- 
Steven.




More information about the Python-list mailing list