dbm 实例为 false
在 python 2.6.5 中,dbm 的实例没有 __nonzero__ 或 __len__ 方法,那么为什么它会将 false 计算为布尔值呢?
>>> a = dbm.open( 'foo', 'c' ) >>> if a: print 'true' ... >>>
In python 2.6.5, an instance of dbm does not have a __nonzero__ or a __len__ method, so why does it evaluate false as a boolean?
>>> a = dbm.open( 'foo', 'c' ) >>> if a: print 'true' ... >>>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据python文档,值的类型之一是被认为是假的是
由于
dbm
对象是一个映射并且新实例是空的,因此它是错误的。According to the python documentation one of the types of values that is considered false is
Since a
dbm
object is a mapping and a new instance is empty, it is therefore false.