看 PyCon 2015 视频学习到的内容

2015-04-25 08:52:43 +08:00
 ruoyu0088
下面的表达式的结果是:

False is False is False

下面哪个更快? +=还是extend()?:

ba = bytearray()

ba += ....
ba.extend(...)

使用super()和多继承可以改变父类的搜索顺序。
4375 次点击
所在节点    Python
12 条回复
pyKun
2015-04-25 09:49:04 +08:00
False is False is False 这个竟然是 True =,=
c
2015-04-25 09:50:45 +08:00
False is False is False -> True 求科普
dofine
2015-04-25 10:01:13 +08:00
@pyKun
@c
Chaining operators like a is b is c is equivalent to a is b and b is c. So the first example is False is False and False is False, which evaluates to True and True which evaluates to True Having parenthesis leads to the result of one evaluation being compared with the next variable (as you say you expect), so (a is b) is c compares the result of a is b with c.

(http://stackoverflow.com/questions/28104393/why-does-false-is-false-is-false-evaluate-to-true)
eeeeeeve
2015-04-25 10:03:48 +08:00
视频链接在哪里?
bcxx
2015-04-25 10:04:35 +08:00
@c
@pyKun

这个你按照 1 <= 1 <= 1 来了解
bcxx
2015-04-25 10:07:43 +08:00
newghost
2015-04-25 10:16:07 +08:00
ericls
2015-04-25 10:20:20 +08:00
@c Python 就是这点爽

可以直接写 1 <= 2 == 2 <= 3
eeeeeeve
2015-04-25 10:30:50 +08:00
@newghost 这些是ppt吧?
reorx
2015-04-25 10:36:46 +08:00
今年印象最深的是 Guido 关于 Diversity 的那一场,全程满槽点,给大家看我和小伙伴讨论时的截屏



reorx
2015-04-25 10:44:11 +08:00
laike9m
2015-04-25 20:41:45 +08:00
说实话,我认为这种 inconsistent 的东西没必要太纠结,说不定下个版本或另一个 Python 实现里就是另一种更快。倒是 Raymond 的那个 beyond pep8 演讲非常好,推荐去看。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/186174

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX