V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  l1093178  ›  全部回复第 5 页 / 共 6 页
回复总数  114
1  2  3  4  5  6  
2017-11-07 01:11:27 +08:00
回复了 SimbaPeng 创建的主题 Python 我想知道 Python 的类中到底有没有建立作用域?
至于为什么要这么设计,估计就是一些非常奇怪的历史性问题了,@zhy0216 提到的 PEP-227 也许值得一读
2017-11-07 01:03:41 +08:00
回复了 SimbaPeng 创建的主题 Python 我想知道 Python 的类中到底有没有建立作用域?
TL; DR 类在定义的时候是有作用域的,这个作用域内的变量只能在 class 块内访问,而不能在类的方法(函数)中访问。

这种问题当然应该是去看 Language Reference 啦

Python 3: https://docs.python.org/3/reference/executionmodel.html#naming-and-binding

> The following constructs bind names: formal parameters to functions, import statements, class and function definitions (these bind the class or function name in the defining block) ...

然后

> Class definition blocks and arguments to exec() and eval() are special in the context of name resolution. A class definition is an executable statement that may use and define names. These references follow the normal rules for name resolution with an exception that unbound local variables are looked up in the global namespace. The namespace of the class definition becomes the attribute dictionary of the class. The scope of names defined in a class block is limited to the class block; it does not extend to the code blocks of methods – this includes comprehensions and generator expressions since they are implemented using a function scope.
2017-10-23 22:03:56 +08:00
回复了 est 创建的主题 奇思妙想 [脑洞] 国内这么多搞 AI 智能音响的
卧槽这不是 1984 里面的电幕么
2017-09-18 17:53:01 +08:00
回复了 hanwang 创建的主题 程序员 海外漂了十年的程序员想回国:北京雾霾真的很严重么
要注意中国 AQI 的标准和美国 AQI 的标准是不一样的,中国的良在美国可能就是重度污染,要对比最好先换算到同一套标准再对比
2017-08-19 14:32:53 +08:00
回复了 staticor 创建的主题 互联网 在中国互联网可以完全不用 Baidu 家的产品服务么?
偶尔网盘下东西,其他都不用
2017-08-18 14:04:29 +08:00
回复了 yulitian888 创建的主题 职场话题 吐个槽,第一次和面试的吵起来
@yulitian888 考个不侮辱智商的,让他用正则识别 7 的倍数
2017-08-02 18:45:45 +08:00
回复了 chengfu 创建的主题 奇思妙想 关于那些买断变订阅软件的建议
@chengfu 如果你要一直更新,买断价格的算法就是 @geelaw 这样的。
很多订阅软件不续订就不能用了,这才是最烦的地方( Jetbrains 至少订满一年有 Perpetual fallback license )
当然还有买断制的软件,隔个一两年就升级一波大版本加些不痛不痒的新功能(比如 Dash )
2017-07-26 18:27:58 +08:00
回复了 hematite 创建的主题 问与答 最长寿、石器时代的中文网站,有哪些?
http://heroworld.gamerhome.com/
英雄世界,英雄无敌系列游戏攻略站 & 社区
Copyright 是从 1999 年开是的
办公室政治这么多的公司,不跑路等着过年?
2017-07-22 17:38:12 +08:00
回复了 wxxshu 创建的主题 全球工单系统 UCloud 关于 Laravist 社区事件的说明
@laogui 这里明显是 Ucloud 自己没清晰定义「有效用户」,自己没说清楚活动规则,怎么就成「双方都有错」了
2017-07-19 18:48:23 +08:00
回复了 yongshou 创建的主题 分享发现 WhatsApp,已卒。。。
之前确实没被封的
vagrant + ansible 可行;外部服务( MySQL Redis )的话还是用 docker 更方便一点。
以及,用什么其实不是特别重要,重要的是脚本的维护。
2017-07-17 19:32:19 +08:00
回复了 biocom 创建的主题 MySQL 整数 int 类型的数据(如订单号)有必要加索引吗?
通常来说根据集合的 cardinality 来决定要不要加索引比较好
理财也要分男女?
2017-06-29 19:13:07 +08:00
回复了 cid 创建的主题 分享发现 再次推荐 Notion.so ,简直像当初发现 markdown 一样兴奋
2017-06-20 13:20:26 +08:00
回复了 est 创建的主题 Python Intel® Distribution for Python
反正 macOS 下面的 Python 只拿来做开发 😂
2017-06-15 15:25:52 +08:00
回复了 Felldeadbird 创建的主题 职场话题 公司催工直接打到我家人那里
@KIDJourney 重要系统应该是安排人轮班,而不是要求人 24 小时待命吧
2017-06-13 16:06:06 +08:00
回复了 ChristopherWu 创建的主题 程序员 你们仍未掌握那天所学的 git 知识
还有非常好用的 git commit --amend 和 git commit --fixup
前者可以修改上一个提交的内容;
后者可以加一个 !fixup commit,配合 git rebase --autosquash 可以自动帮你修复之前的 commit
1  2  3  4  5  6  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1388 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 48ms · UTC 17:24 · PVG 01:24 · LAX 10:24 · JFK 13:24
Developed with CodeLauncher
♥ Do have faith in what you're doing.