流行方法问题 [英] pop method question

查看:73
本文介绍了流行方法问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Howdy Folks,


我只是在交互式提示下在IDLE中玩耍并在dir({})中键入

以获得乐趣。我很惊讶地看到在那里定义了一个流行的

方法。我的意思是用词不当还是什么?从

文献来看,pop应该是为堆栈定义的操作

数据结构。堆栈被定义为有序的堆栈。列表数据

结构。 Python中的字典没有顺序,但是序列。

现在,有没有人知道为什么python核心有这种pop方法

为字典类型实现了?


我意识到在这种情况下它用于从当前字典对象中删除特定键

。但是为什么称它为pop而不是

更直观的东西如删除或删除?


感谢提前澄清:)。


--Nick

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 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?

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?

Thanks for the clarification in advance :).

--Nick


推荐答案

Nicholas Parsons< pa ******* ********@gmail.com写道:
Nicholas Parsons <pa***************@gmail.comwrote:

我意识到在这种情况下它用于删除特定的密钥

来自当前字典对象。但是为什么称它为pop而不是像b / b
更直观的东西,如删除或删除?
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?



我不是python程序员,但我猜它是'b
因为pop不会删除键,它返回值为

井。

-

Web(en): http://www.no-spoon.de/ - * - Web(de): http://www.frell.de/

I wasn''t a python programmer back than, but I''d guess it''s
because pop not just removes the key, it returns the value as
well.
--
Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/


Nicholas Parsons< pa *************** @ gmail.comwrites:
Nicholas Parsons <pa***************@gmail.comwrites:

我刚刚在交互式的IDLE中玩耍提示并键入

in dir({})以获得乐趣。我很惊讶地看到在那里定义了一个流行的

方法。我的意思是用词不当还是什么?从

文献来看,pop应该是为堆栈定义的操作

数据结构。堆栈被定义为有序的堆栈。列表数据

结构。 Python中的字典没有顺序,但是序列。

现在,有没有人知道为什么python核心有这种流行方法

为字典类型实现?
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?



尝试输入:


help({}。pop)

Try typing:

help({}.pop)




2007年3月3日下午3:49,Paul Rubin写道:

On Mar 3, 2007, at 3:49 PM, Paul Rubin wrote:

Nicholas Parsons< pa ** *************@gmail.com写:
Nicholas Parsons <pa***************@gmail.comwrites:

>我刚刚在交互式提示符下玩IDLE并输入<在dir({})中获取它的乐趣。我很惊讶地看到在那里定义了一个流行的
方法。我的意思是用词不当还是什么?从
文献来看,pop应该是为堆栈数据结构定义的操作。堆栈被定义为有序的堆栈。列表数据
结构。 Python中的字典没有顺序,但是序列。
现在,有没有人知道为什么python核心为字典类型实现了这种pop方法?
>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?



尝试输入:


help({}。pop)

-
http://mail.python.org/mailman/listinfo/ python-list



谢谢,这给出了更详细的说明行为是什么
但是没有回答我上面的问题: (

Thanks, that gives a more details explanation of what the behavior is
but doesn''t answer my question above :(


这篇关于流行方法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆