En Sat, 03 Mar 2007 19:55:16 -0300, Steven D'Aprano
<[EMAIL PROTECTED]> escribió:
> I personally don't see that pop has any advantage, especially since the
> most useful example
>
> while some_dict:
> do_something_with(some_dict.pop())
>
> doesn't work. Instead you have to write this:
For s
On Sun, 04 Mar 2007 07:36:50 -0500, Nicholas Parsons wrote:
> Hi Jordan,
>
> That is true what you say about pop() behavior with stack-like
> objects. But the definition of pop() for a stack-like structure is
> stronger than that.
That's okay, we're not talking about pop for stack-like stru
On Mar 4, 2007, at 4:38 AM, Marc 'BlackJack' Rintsch wrote:
> In <[EMAIL PROTECTED]>, Nicholas
> Parsons wrote:
>
>> Just from my computer science background when I see pop(), I think
>> of a
>> stack data structure.
>
> Then question your presumptions. There are also many people thinking
> `l
Hi Jordan,
That is true what you say about pop() behavior with stack-like
objects. But the definition of pop() for a stack-like structure is
stronger than that. A stack is a LIFO data structure. Therefore the
pop() operation is defined to not only mutate the receiver and return
the item
In <[EMAIL PROTECTED]>, Nicholas
Parsons wrote:
> Just from my computer science background when I see pop(), I think of a
> stack data structure.
Then question your presumptions. There are also many people thinking
`list` must be something with nodes and pointers when they see the
interface and
"Alex Martelli" <[EMAIL PROTECTED]> wrote:
> Raymond Hettinger <[EMAIL PROTECTED]> wrote:
>...
> > The notion that "pop" is only defined for stack operations is somewhat
> > pedantic.
>
> Worse: it's totally wrong. It's also defined for eyes, as a musical
> genre, as a kind of soda, as an a
Nick,
In regards to stack-like objects, pop() implies mutation of the
reciever and returning the item 'popped' off the stack. The same
_semantic_ meaning can be used for pop() regarding dictionaries, even
though the _implementation_ would be different: dict.pop(key) mutates
the reciever and return
Hi Raymond,
Thank you for your clarification below. I was just using "remove"
and "delete" as possible alternatives to the name "pop" without much
contemplation. Like you say below, it begs the question as to why
not have two separate operations for dictionaries (retrieval of value
from
Raymond Hettinger <[EMAIL PROTECTED]> wrote:
...
> The notion that "pop" is only defined for stack operations is somewhat
> pedantic.
Worse: it's totally wrong. It's also defined for eyes, as a musical
genre, as a kind of soda, as an avant-garde artistic movement of the
'50s, for baloons, as a
Steven D'Aprano <[EMAIL PROTECTED]> wrote:
...
> while some_dict:
> do_something_with(some_dict.pop())
>
> doesn't work. Instead you have to write this:
You have to use .popitem for this -- that's what's it's for...
Alex
--
http://mail.python.org/mailman/listinfo/python-list
[Nicholas Parsons]
> 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?
>
> I realize that in this context it is used for removing a specific key
> from the current dictionary object. B
Steven D'Aprano wrote:
> On Sat, 03 Mar 2007 23:22:10 +, James Stroud wrote:
>
>>> To my mind, having to supply a key to dict.pop makes it rather pointless.
>>>
>>>
>>
>> I've used it in something like this and found it worthwhile:
>>
>> for akey in dict1:
>>if some_condition(akey):
>>
On Sat, 03 Mar 2007 15:36:14 -0800, Paul Rubin wrote:
> James Stroud <[EMAIL PROTECTED]> writes:
>> for akey in dict1:
>>if some_condition(akey):
>> dict2[akey] = dict2.pop(akey)
>>
>> Which necessitates a key is a little cleaner than your latter example.
>
> Yeah, I also think removing
On Sat, 03 Mar 2007 23:22:10 +, James Stroud wrote:
>> To my mind, having to supply a key to dict.pop makes it rather pointless.
>>
>>
>
>
> I've used it in something like this and found it worthwhile:
>
> for akey in dict1:
>if some_condition(akey):
> dict2[akey] = dict2.pop(ake
James Stroud <[EMAIL PROTECTED]> writes:
> for akey in dict1:
>if some_condition(akey):
> dict2[akey] = dict2.pop(akey)
>
> Which necessitates a key is a little cleaner than your latter example.
Yeah, I also think removing keys from a dict while iterating over it
(like in Steven's exampl
Steven D'Aprano wrote:
> I personally don't see that pop has any advantage, especially since the
> most useful example
>
> while some_dict:
> do_something_with(some_dict.pop())
>
> doesn't work. Instead you have to write this:
>
> for key in some_dict.keys():
> # can't iterate over the
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 <[EMAIL PROTECTED]>
> writes:
>> >> I was just playing around in IDLE at the
>> >> interactive prompt and ty
On Saturday 03 March 2007 15:56, Nicholas Parsons
wrote:
> On Mar 3, 2007, at 3:49 PM, Paul Rubin wrote:
> > Nicholas Parsons <[EMAIL PROTECTED]>
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 se
On Sat, 03 Mar 2007 15:56:39 -0500, Nicholas Parsons wrote:
>
> On Mar 3, 2007, at 3:49 PM, Paul Rubin wrote:
>
>> Nicholas Parsons <[EMAIL PROTECTED]> 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 se
On Mar 3, 2007, at 3:49 PM, Paul Rubin wrote:
> Nicholas Parsons <[EMAIL PROTECTED]> 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?
Nicholas Parsons <[EMAIL PROTECTED]> 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 opera
Nicholas Parsons <[EMAIL PROTECTED]> wrote:
> I realize that in this context it is used for removing a specific key
> from the current dictionary object. But why call it pop and not
> something more intuitive like remove or delete?
I wasn't a python programmer back than, but I'd guess it's
be
Howdy Folks,
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 s
23 matches
Mail list logo