V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  u2386  ›  全部回复第 2 页 / 共 2 页
回复总数  29
1  2  
2017-10-17 10:08:31 +08:00
回复了 kindjeff 创建的主题 分享发现 吐槽一发滴滴的 2018 校招面试
传参传对象。
2017-10-07 21:30:56 +08:00
回复了 changwei 创建的主题 JetBrains 为什么 JetBrains 的 IDE 永远都这么卡?
jb:卡怎么会是我的缺点,难道不是你电脑配置太低🤷‍♂️
2017-09-23 18:24:49 +08:00
回复了 gap 创建的主题 JavaScript 如何限制只允许用户在表单中输入十进制的数呢?
怎么判断 1 是什么进制。

让用户必须输入 9 不准输入字母...
2017-09-15 13:52:14 +08:00
回复了 symons 创建的主题 程序员 讨论帖, IDE 相较于 vim 有哪些优势
相反,我认为初学者可以用 IDE 来辅助自己学习编程,能有效防止自己犯比较初级的错误。而已经熟练的用编辑器写地更自由。
2017-08-24 00:45:56 +08:00
回复了 saximi 创建的主题 Python 请教一个关于__getattr__的问题
以下摘自[https://docs.python.org/2/reference/datamodel.html#object.__getattribute__]

object.__getattribute__(self, name)

Called unconditionally to implement attribute accesses for instances of the class. If the class also defines getattr(), the latter will not be called unless getattribute() either calls it explicitly or raises an AttributeError. This method should return the (computed) attribute value or raise an AttributeError exception. In order to avoid infinite recursion in this method, its implementation should always call the base class method with the same name to access any attributes it needs, for example, object.getattribute(self, name).


所以第一个实现,通过__getattr__里查找一个不存在的属性 wrapped,但是在最后又一次使用 self.wrapped,递归就发生了。

第二个实现之所以没有问题,是因为 wrapped 已经存在,并且是 aClass 的实例。


另:推荐 pdb 查问题。
2017-08-24 00:32:04 +08:00
回复了 saximi 创建的主题 Python 请教一个关于__getattr__的问题
先不说别的。

你的第一个实现,onInstance 的__init__方法中 aClass 是一个 str ——'X is',既你之后调用__call__也是会报错的。
2017-08-23 09:42:00 +08:00
回复了 gogobody 创建的主题 Python 请问 Python 判断 2 个时间段是否有交集 有什么好的方法吗?
@Or2 同好奇
2017-08-21 18:36:31 +08:00
回复了 waiaan 创建的主题 编辑器 有多少人从 sublime 转投 vs code 了?
🙋‍♂️
1  2  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3101 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 24ms · UTC 14:52 · PVG 22:52 · LAX 07:52 · JFK 10:52
Developed with CodeLauncher
♥ Do have faith in what you're doing.