@@ -2536,12 +2536,14 @@ msgid ""
25362536"``__init_subclass__``, one should take out the needed keyword arguments and "
25372537"pass the others over to the base class, as in::"
25382538msgstr ""
2539+ "传入一个新类的关键字参数会被传给父类的 ``__init_subclass__``。为了与其他使用 ``__init_subclass__`` "
2540+ "的类兼容,应当根据需要去掉部分关键字参数再将其余的传给基类,例如::"
25392541
25402542#: ../../reference/datamodel.rst:1817
25412543msgid ""
25422544"The default implementation ``object.__init_subclass__`` does nothing, but "
25432545"raises an error if it is called with any arguments."
2544- msgstr ""
2546+ msgstr "``object.__init_subclass__`` 的默认实现什么都不做,只在带任意参数调用时引发一个错误。 "
25452547
25462548#: ../../reference/datamodel.rst:1822
25472549msgid ""
@@ -2550,17 +2552,21 @@ msgid ""
25502552" actual metaclass (rather than the explicit hint) can be accessed as "
25512553"``type(cls)``."
25522554msgstr ""
2555+ "元类提示 ``metaclass`` 将被其它类型机制消耗掉,并不会被传给 ``__init_subclass__`` "
2556+ "的实现。实际的元类(而非显式的提示)可通过 ``type(cls)`` 访问。"
25532557
25542558#: ../../reference/datamodel.rst:1833
25552559msgid "Metaclasses"
2556- msgstr ""
2560+ msgstr "元类 "
25572561
25582562#: ../../reference/datamodel.rst:1840
25592563msgid ""
25602564"By default, classes are constructed using :func:`type`. The class body is "
25612565"executed in a new namespace and the class name is bound locally to the "
25622566"result of ``type(name, bases, namespace)``."
25632567msgstr ""
2568+ "默认情况下,类是使用 :func:`type` 来构建的。类体会在一个新的命名空间内执行,类名会被局部绑定到 ``type(name, bases, "
2569+ "namespace)`` 的结果。"
25642570
25652571#: ../../reference/datamodel.rst:1844
25662572msgid ""
@@ -2569,40 +2575,42 @@ msgid ""
25692575"existing class that included such an argument. In the following example, "
25702576"both ``MyClass`` and ``MySubclass`` are instances of ``Meta``::"
25712577msgstr ""
2578+ "类创建过程可通过在定义行传入 ``metaclass`` 关键字参数,或是通过继承一个包含此参数的现有类来进行定制。在以下示例中,``MyClass``"
2579+ " 和 ``MySubclass`` 都是 ``Meta`` 的实例::"
25722580
25732581#: ../../reference/datamodel.rst:1858
25742582msgid ""
25752583"Any other keyword arguments that are specified in the class definition are "
25762584"passed through to all metaclass operations described below."
2577- msgstr ""
2585+ msgstr "在类定义内指定的任何其他关键字参数都会在下面所描述的所有元类操作中进行传递。 "
25782586
25792587#: ../../reference/datamodel.rst:1861
25802588msgid "When a class definition is executed, the following steps occur:"
2581- msgstr ""
2589+ msgstr "当一个类定义被执行时,将发生以下步骤: "
25822590
25832591#: ../../reference/datamodel.rst:1863
25842592msgid "MRO entries are resolved"
2585- msgstr ""
2593+ msgstr "解析 MRO 条目 "
25862594
25872595#: ../../reference/datamodel.rst:1864
25882596msgid "the appropriate metaclass is determined"
2589- msgstr ""
2597+ msgstr "确定适当的元类 "
25902598
25912599#: ../../reference/datamodel.rst:1865
25922600msgid "the class namespace is prepared"
2593- msgstr ""
2601+ msgstr "准备类命名空间 "
25942602
25952603#: ../../reference/datamodel.rst:1866
25962604msgid "the class body is executed"
2597- msgstr ""
2605+ msgstr "执行类主体 "
25982606
25992607#: ../../reference/datamodel.rst:1867
26002608msgid "the class object is created"
2601- msgstr ""
2609+ msgstr "创建类对象 "
26022610
26032611#: ../../reference/datamodel.rst:1871
26042612msgid "Resolving MRO entries"
2605- msgstr ""
2613+ msgstr "解析 MRO 条目 "
26062614
26072615#: ../../reference/datamodel.rst:1873
26082616msgid ""
@@ -2612,19 +2620,21 @@ msgid ""
26122620" tuple of classes that will be used instead of this base. The tuple may be "
26132621"empty, in such case the original base is ignored."
26142622msgstr ""
2623+ "如果在类定义中出现的基类不是 :class:`type` 的实例,则使用 ``__mro_entries__`` "
2624+ "方法对其进行搜索,当找到结果时,它会以原始基类元组做参数进行调用。此方法必须返回类的元组以替代此基类被使用。元组可以为空,在此情况下原始基类将被忽略。"
26152625
26162626#: ../../reference/datamodel.rst:1881 ../../reference/datamodel.rst:2069
26172627msgid ":pep:`560` - Core support for typing module and generic types"
2618- msgstr ""
2628+ msgstr ":pep:`560` - 对类型模块和泛型类型的核心支持 "
26192629
26202630#: ../../reference/datamodel.rst:1885
26212631msgid "Determining the appropriate metaclass"
2622- msgstr ""
2632+ msgstr "确定适当的元类 "
26232633
26242634#: ../../reference/datamodel.rst:1889
26252635msgid ""
26262636"The appropriate metaclass for a class definition is determined as follows:"
2627- msgstr ""
2637+ msgstr "为一个类定义确定适当的元类是根据以下规则: "
26282638
26292639#: ../../reference/datamodel.rst:1891
26302640msgid ""
0 commit comments