@@ -11,7 +11,7 @@ msgid ""
1111msgstr ""
1212"Project-Id-Version : Python 3.11\n "
1313"Report-Msgid-Bugs-To : \n "
14- "POT-Creation-Date : 2024-03-22 16:49 +0000\n "
14+ "POT-Creation-Date : 2024-03-29 16:43 +0000\n "
1515"PO-Revision-Date : 2023-05-24 02:11+0000\n "
1616"
Last-Translator :
Rafael Fontenelle <[email protected] >, 2024\n "
1717"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -43,7 +43,7 @@ msgid ""
4343" annotations dicts. If you write Python code that examines "
4444"``__annotations__`` on Python objects, we encourage you to follow the "
4545"guidelines described below."
46- msgstr "本文档旨在概括与注解字典打交道的最佳实践。查看 Python 对象的 ``__annotations__`` 的代码应遵循下述准则 。"
46+ msgstr "本文档旨在概括与注解字典打交道的最佳实践。查看 Python 对象的 ``__annotations__`` 的代码应遵循下面的准则 。"
4747
4848#: ../../howto/annotations.rst:16
4949msgid ""
@@ -64,8 +64,7 @@ msgid ""
6464"information on how to use \" type hints\" in your code, please see the "
6565":mod:`typing` module."
6666msgstr ""
67- "本文是 ``__annotations__`` 的文档,不是介绍注解用法的文档。如果要查找关于如何使用“类型提示”的信息,请参阅 "
68- ":mod:`typing` 模块。"
67+ "本文是 ``__annotations__`` 的文档,不是注解的用法。如果在寻找如何使用“类型提示”,请参阅 :mod:`typing` 模块。"
6968
7069#: ../../howto/annotations.rst:33
7170msgid "Accessing The Annotations Dict Of An Object In Python 3.10 And Newer"
@@ -108,7 +107,7 @@ msgid ""
108107msgstr ""
109108"不过,其它类型的可调用对象可不一定定义了 ``__annotations__`` 属性,就比如说,:func:`functools.partial` "
110109"创建的可调用对象。当访问某个未知对象的 ``__annotations__`` 时,3.10 及更高版本的 Python 中的最佳实践是用三个参数去调用"
111- " :func:`getattr`,类似 ``getattr(o, '__annotations__', None)`` 这样。"
110+ " :func:`getattr`,像 ``getattr(o, '__annotations__', None)`` 这样。"
112111
113112#: ../../howto/annotations.rst:60
114113msgid ""
@@ -117,8 +116,8 @@ msgid ""
117116"parent's ``__annotations__``. In Python 3.10 and newer, the child class's "
118117"annotations will be an empty dict instead."
119118msgstr ""
120- "Python 3.10 之前,在一个没定义注解而父类定义了注解的类上访问 ``__annotations__`` 将返回父类的 "
121- "``__annotations__``。在 3.10 及更高版本的 Python 中,这样的子类的标注是一个空字典 。"
119+ "Python 3.10 之前,在一个没定义注解而其父类定义了注解的类上访问 ``__annotations__`` 将返回父类的 "
120+ "``__annotations__``。在 3.10 及更高版本的 Python 中,这样的子类的注解是个空字典 。"
122121
123122#: ../../howto/annotations.rst:68
124123msgid "Accessing The Annotations Dict Of An Object In Python 3.9 And Older"
@@ -151,12 +150,13 @@ msgid ""
151150"``__annotations__`` attribute of a class may inadvertently return the "
152151"annotations dict of a *base class.* As an example::"
153152msgstr ""
154- "不幸的是,对于类而言,这并不是最佳做法。因为 ```__annotations__`` 是类的可选属性,并且类可以从基类继承属性,访问某个类的 "
155- "``__annotations__`` 属性可能会无意间返回 *基类* 的注解数据。例如:"
153+ "不幸的是,对类而言,这并不是最佳实践。问题在于,由于 ``__annotations__`` "
154+ "在某个类上是可有可无的,而类又可以从基类继承属性,所以访问某个类的 ``__annotations__`` 属性可能会无意间返回 *基类* "
155+ "的注解字典。如:"
156156
157157#: ../../howto/annotations.rst:98
158158msgid "This will print the annotations dict from ``Base``, not ``Derived``."
159- msgstr "如此会打印出 ``Base`` 的注解字典,而非 ``Derived`` 的。"
159+ msgstr "会打印出 ``Base`` 的注解字典,而非 ``Derived`` 的。"
160160
161161#: ../../howto/annotations.rst:101
162162msgid ""
@@ -167,9 +167,9 @@ msgid ""
167167" Since the class may or may not have annotations defined, best practice is "
168168"to call the ``get`` method on the class dict."
169169msgstr ""
170- "若要查看的对象是个类( ``isinstance(o, type)``),代码不得不另辟蹊径。这时的最佳做法依赖于 Python 3.9 "
171- "及之前版本的一处细节:若某个类定义了注解,则会存放于字典 ``__dict__`` 中。由于类不一定会定义注解,最好的做法是在类的 dict 上调用 "
172- "``get`` 方法。"
170+ "若待检查的对象是类(即 ``isinstance(o, type)``),代码不得不另辟蹊径。这时的最佳实践依赖于 3.9 及更低版本的 Python "
171+ "中的一处实现细节:若类定义了注解,则注解会被放入类的 ``__dict__`` 字典。类不一定有注解,故最佳实践是在类的字典上调用 ``get`` "
172+ "方法。"
173173
174174#: ../../howto/annotations.rst:109
175175msgid ""
@@ -328,7 +328,7 @@ msgstr "应避免删除对象的 ``__annotations__`` 属性。"
328328
329329#: ../../howto/annotations.rst:198
330330msgid "``__annotations__`` Quirks"
331- msgstr "``__annotations__`` 的坑 "
331+ msgstr "``__annotations__`` 的一些“坑” "
332332
333333#: ../../howto/annotations.rst:200
334334msgid ""
0 commit comments