@@ -2279,6 +2279,9 @@ msgid ""
22792279"precision, see :func:`math.fsum`\\ . To concatenate a series of iterables, "
22802280"consider using :func:`itertools.chain`."
22812281msgstr ""
2282+ "对某些用例来说,存在 :func:`sum` 的更好替代。 拼接字符串序列的更好更快方式是调用 ``''.join(sequence)``。 "
2283+ "要以扩展精度对浮点值求和,请参阅 :func:`math.fsum`。 要拼接一系列可迭代对象,请考虑使用 "
2284+ ":func:`itertools.chain`。"
22822285
22832286#: ../../library/functions.rst:1494
22842287msgid ""
@@ -2287,6 +2290,8 @@ msgid ""
22872290"been overridden in a class. The search order is same as that used by "
22882291":func:`getattr` except that the *type* itself is skipped."
22892292msgstr ""
2293+ "返回一个代理对象,它会将方法调用委托给 *type* 指定的父类或兄弟类。 这对于访问已在类中被重载的继承方法很有用。 搜索顺序与 "
2294+ ":func:`getattr` 所使用的相同,只是 *type* 指定的类型本身会被跳过。"
22902295
22912296#: ../../library/functions.rst:1499
22922297msgid ""
@@ -2295,6 +2300,8 @@ msgid ""
22952300" attribute is dynamic and can change whenever the inheritance hierarchy is "
22962301"updated."
22972302msgstr ""
2303+ "*type* 的 :attr:`~class.__mro__` 属性列出了 :func:`getattr` 和 :func:`super` "
2304+ "所使用的方法解析顺序。 该属性是动态的,可以在继承层级结构更新的时候任意改变。"
22982305
22992306#: ../../library/functions.rst:1504
23002307msgid ""
@@ -2303,6 +2310,8 @@ msgid ""
23032310"If the second argument is a type, ``issubclass(type2, type)`` must be true "
23042311"(this is useful for classmethods)."
23052312msgstr ""
2313+ "如果省略第二个参数,则返回的超类对象是未绑定的。 如果第二个参数为一个对象,则 ``isinstance(obj, type)`` 必须为真值。 "
2314+ "如果第二个参数为一个类型,则 ``issubclass(type2, type)`` 必须为真值(这适用于类方法)。"
23062315
23072316#: ../../library/functions.rst:1509
23082317msgid ""
@@ -2311,6 +2320,8 @@ msgid ""
23112320"naming them explicitly, thus making the code more maintainable. This use "
23122321"closely parallels the use of *super* in other programming languages."
23132322msgstr ""
2323+ "*super* 有两个典型用例。 在具有单继承的类层级结构中,*super* 可用来引用父类而不必显式地指定它们的名称,从而令代码更易维护。 "
2324+ "这种用法与其他编程语言中 *super* 的用法非常相似。"
23142325
23152326#: ../../library/functions.rst:1514
23162327msgid ""
@@ -2324,10 +2335,13 @@ msgid ""
23242335"order adapts to changes in the class hierarchy, and because that order can "
23252336"include sibling classes that are unknown prior to runtime)."
23262337msgstr ""
2338+ "第二个用例是在动态执行环境中支持协作多重继承。 此用例为 Python 所独有,在静态编译语言或仅支持单继承的语言中是不存在的。 "
2339+ "这使得实现“菱形图”成为可能,在这时会有多个基类实现相同的方法。 "
2340+ "好的设计强制要求这种方法在每个情况下具有相同的调用签名(因为调用顺序是在运行时确定的,也因为该顺序要适应类层级结构的更改,还因为该顺序可能包含在运行时之前未知的兄弟类)。"
23272341
23282342#: ../../library/functions.rst:1524
23292343msgid "For both use cases, a typical superclass call looks like this::"
2330- msgstr ""
2344+ msgstr "对于以上两个用例,典型的超类调用看起来是这样的:: "
23312345
23322346#: ../../library/functions.rst:1531
23332347msgid ""
@@ -2338,6 +2352,9 @@ msgid ""
23382352"inheritance. Accordingly, :func:`super` is undefined for implicit lookups "
23392353"using statements or operators such as ``super()[name]``."
23402354msgstr ""
2355+ "请注意 :func:`super` 是作为显式加点属性查找的绑定过程的一部分来实现的,例如 ``super().__getitem__(name)``。"
2356+ " 它做到这一点是通过实现自己的 :meth:`__getattribute__` 方法,这样就能以可预测的顺序搜索类,并且支持协作多重继承。 "
2357+ "对应地,:func:`super` 在像 ``super()[name]`` 这样使用语句或操作符进行隐式查找时则未被定义。"
23412358
23422359#: ../../library/functions.rst:1538
23432360msgid ""
0 commit comments