@@ -2639,19 +2639,19 @@ msgstr "为一个类定义确定适当的元类是根据以下规则:"
26392639#: ../../reference/datamodel.rst:1891
26402640msgid ""
26412641"if no bases and no explicit metaclass are given, then :func:`type` is used"
2642- msgstr ""
2642+ msgstr "如果没有给出基类也没有显式元类,则使用 :func:`type` "
26432643
26442644#: ../../reference/datamodel.rst:1892
26452645msgid ""
26462646"if an explicit metaclass is given and it is *not* an instance of "
26472647":func:`type`, then it is used directly as the metaclass"
2648- msgstr ""
2648+ msgstr "如果给出一个显式元类而且 *不是* :func:`type` 的实例,则其会被直接用作元类 "
26492649
26502650#: ../../reference/datamodel.rst:1894
26512651msgid ""
26522652"if an instance of :func:`type` is given as the explicit metaclass, or bases "
26532653"are defined, then the most derived metaclass is used"
2654- msgstr ""
2654+ msgstr "如果给出一个 :func:`type` 的实例作为显式元类,或是定义了基类,则使用最近派生的元类 "
26552655
26562656#: ../../reference/datamodel.rst:1897
26572657msgid ""
@@ -2661,10 +2661,12 @@ msgid ""
26612661" of these candidate metaclasses. If none of the candidate metaclasses meets "
26622662"that criterion, then the class definition will fail with ``TypeError``."
26632663msgstr ""
2664+ "最近派生的元类会从显式指定的元类(如果有)以及所有指定的基类的元类(即 ``type(cls)``)中选取。最近派生的元类应为 *所有* "
2665+ "这些候选元类的一个子类型。如果没有一个候选元类符合该条件,则类定义将失败并抛出 ``TypeError``。"
26642666
26652667#: ../../reference/datamodel.rst:1907
26662668msgid "Preparing the class namespace"
2667- msgstr ""
2669+ msgstr "准备类命名空间 "
26682670
26692671#: ../../reference/datamodel.rst:1912
26702672msgid ""
@@ -2673,24 +2675,26 @@ msgid ""
26732675" as ``namespace = metaclass.__prepare__(name, bases, **kwds)`` (where the "
26742676"additional keyword arguments, if any, come from the class definition)."
26752677msgstr ""
2678+ "一旦适当的元类被确定,则类命名空间将会准备好。如果元类具有 ``__prepare__`` 属性,它会以 ``namespace = "
2679+ "metaclass.__prepare__(name, bases, **kwds)`` 的形式被调用(其中如果有附加的关键字参数,应来自类定义)。"
26762680
26772681#: ../../reference/datamodel.rst:1917
26782682msgid ""
26792683"If the metaclass has no ``__prepare__`` attribute, then the class namespace "
26802684"is initialised as an empty ordered mapping."
2681- msgstr ""
2685+ msgstr "如果元类没有 ``__prepare__`` 属性,则类命名空间将初始化为一个空的有序映射。 "
26822686
26832687#: ../../reference/datamodel.rst:1922
26842688msgid ":pep:`3115` - Metaclasses in Python 3000"
2685- msgstr ""
2689+ msgstr ":pep:`3115` - Python 3000 中的元类 "
26862690
26872691#: ../../reference/datamodel.rst:1923
26882692msgid "Introduced the ``__prepare__`` namespace hook"
2689- msgstr ""
2693+ msgstr "引入 ``__prepare__`` 命名空间钩子 "
26902694
26912695#: ../../reference/datamodel.rst:1927
26922696msgid "Executing the class body"
2693- msgstr ""
2697+ msgstr "执行类主体 "
26942698
26952699#: ../../reference/datamodel.rst:1932
26962700msgid ""
@@ -2700,6 +2704,8 @@ msgid ""
27002704"names from the current and outer scopes when the class definition occurs "
27012705"inside a function."
27022706msgstr ""
2707+ "类主体会以(类似于) ``exec(body, globals(), namespace)`` 的形式被执行。普通调用与 :func:`exec` "
2708+ "的关键区别在于当类定义发生于函数内部时,词法作用域允许类主体(包括任何方法)引用来自当前和外部作用域的名称。"
27032709
27042710#: ../../reference/datamodel.rst:1938
27052711msgid ""
0 commit comments