#pragma section-numbers off <> 以下是 Dip 原版的勘误。勘误表中指出的错误在 4.5b 版中均已修正。 = 5. 对象和面向对象 = == 5.2 使用 from module import 导入模块 == `Para 2`:注意粗体部分。代码中显示的被导入的对象是 '''UserDict 类''',而不是 '''types 模块的属性和方法'''。<
> ''Here is the basic from module import syntax:<
> `from UserDict import UserDict`<
> This is similar to the import module syntax that you know and love, but with an important difference: '''the attributes and methods of the imported module `types`''' are imported directly into the local namespace, so they are available directly, without qualification by module name.''<
> 下面是 from module import 的基本语法:<
> `from UserDict import UserDict`<
> 它与你所熟知的 import module 语法很相似,但是有一个重要的区别:'''被导入模块 types 的属性和方法被直接导入到局部名字空间去了,所以它们可以直接使用''',而不需要加上模块名的限定。<
> (./) UserDict 被直接导入到局部名字空间去了,所以它可以直接使用,而不需要加上模块名的限定。 = 7. 正则表达式 = == 7.4 使用 {n,m} 语法 == 其实本节的问题 Zoomq 在翻译的时候就已经指出了,只是出于忠实原文的考虑,没有改动。罗马数字语法矛盾的问题通过简单修改代码即可完美解决。 = 12. SOAP Web 服务 = == 12.6 以 WSDL 进行 SOAP 内省 == `例 12.8`:注意第二行多了一个右括号。 {{{ >>> from SOAPpy import WSDL >>> wsdlFile = 'http://www.xmethods.net/sd/2001/TemperatureService.wsdl') >>> server = WSDL.Proxy(wsdlFile) >>> server.methods.keys() [u'getTemp'] }}} = 16. 函数编程 = == 16.3 重识列表过滤 == `例16.7, (1)`:''odd uses the built-in mod function "%" to return `True` if n is odd and `False` if n is even.''<
> odd 使用内建的取模(mod)函数 "%" 对于为奇数的 n 返回 `True`;为偶数的返回 `False`。<
> (./) odd 使用内建的取模(mod)函数 "%" 对于为奇数的 n 返回 1;为偶数的返回 0。<
> (!) 1 和 0 被 typo 为 True 和 False 是有原因的,你可以在修订历史里面找到。Mark 在 Dip 的早期版本中(那时 Python 还没有独立的 bool 类型)把 True, False 与 1, 0 都混用了,后来可能是用了盲目替换,自己都被弄懵了。 = 18. 性能优化 = <>