@@ -11,7 +11,7 @@ msgid ""
11
11
msgstr ""
12
12
"Project-Id-Version : Python 3.10\n "
13
13
"Report-Msgid-Bugs-To : \n "
14
- "POT-Creation-Date : 2024-03-22 19:02 +0000\n "
14
+ "POT-Creation-Date : 2024-03-29 19:16 +0000\n "
15
15
"PO-Revision-Date : 2022-11-05 17:21+0000\n "
16
16
"
Last-Translator :
Rafael Fontenelle <[email protected] >, 2024\n "
17
17
"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -43,7 +43,7 @@ msgid ""
43
43
" annotations dicts. If you write Python code that examines "
44
44
"``__annotations__`` on Python objects, we encourage you to follow the "
45
45
"guidelines described below."
46
- msgstr "本文档旨在概括与注解字典打交道的最佳实践。查看 Python 对象的 ``__annotations__`` 的代码应遵循下述准则 。"
46
+ msgstr "本文档旨在概括与注解字典打交道的最佳实践。查看 Python 对象的 ``__annotations__`` 的代码应遵循下面的准则 。"
47
47
48
48
#: ../../howto/annotations.rst:16
49
49
msgid ""
@@ -64,8 +64,7 @@ msgid ""
64
64
"information on how to use \" type hints\" in your code, please see the "
65
65
":mod:`typing` module."
66
66
msgstr ""
67
- "本文是 ``__annotations__`` 的文档,不是介绍注解用法的文档。如果要查找关于如何使用“类型提示”的信息,请参阅 "
68
- ":mod:`typing` 模块。"
67
+ "本文是 ``__annotations__`` 的文档,不是注解的用法。如果在寻找如何使用“类型提示”,请参阅 :mod:`typing` 模块。"
69
68
70
69
#: ../../howto/annotations.rst:33
71
70
msgid "Accessing The Annotations Dict Of An Object In Python 3.10 And Newer"
@@ -108,7 +107,7 @@ msgid ""
108
107
msgstr ""
109
108
"不过,其它类型的可调用对象可不一定定义了 ``__annotations__`` 属性,就比如说,:func:`functools.partial` "
110
109
"创建的可调用对象。当访问某个未知对象的 ``__annotations__`` 时,3.10 及更高版本的 Python 中的最佳实践是用三个参数去调用"
111
- " :func:`getattr`,类似 ``getattr(o, '__annotations__', None)`` 这样。"
110
+ " :func:`getattr`,像 ``getattr(o, '__annotations__', None)`` 这样。"
112
111
113
112
#: ../../howto/annotations.rst:60
114
113
msgid ""
@@ -117,8 +116,8 @@ msgid ""
117
116
"parent's ``__annotations__``. In Python 3.10 and newer, the child class's "
118
117
"annotations will be an empty dict instead."
119
118
msgstr ""
120
- "Python 3.10 之前,在一个没定义注解而父类定义了注解的类上访问 ``__annotations__`` 将返回父类的 "
121
- "``__annotations__``。在 3.10 及更高版本的 Python 中,这样的子类的标注是一个空字典 。"
119
+ "Python 3.10 之前,在一个没定义注解而其父类定义了注解的类上访问 ``__annotations__`` 将返回父类的 "
120
+ "``__annotations__``。在 3.10 及更高版本的 Python 中,这样的子类的注解是个空字典 。"
122
121
123
122
#: ../../howto/annotations.rst:68
124
123
msgid "Accessing The Annotations Dict Of An Object In Python 3.9 And Older"
@@ -151,12 +150,13 @@ msgid ""
151
150
"``__annotations__`` attribute of a class may inadvertently return the "
152
151
"annotations dict of a *base class.* As an example::"
153
152
msgstr ""
154
- "不幸的是,对于类而言,这并不是最佳做法。因为 ```__annotations__`` 是类的可选属性,并且类可以从基类继承属性,访问某个类的 "
155
- "``__annotations__`` 属性可能会无意间返回 *基类* 的注解数据。例如:"
153
+ "不幸的是,对类而言,这并不是最佳实践。问题在于,由于 ``__annotations__`` "
154
+ "在某个类上是可有可无的,而类又可以从基类继承属性,所以访问某个类的 ``__annotations__`` 属性可能会无意间返回 *基类* "
155
+ "的注解字典。如:"
156
156
157
157
#: ../../howto/annotations.rst:98
158
158
msgid "This will print the annotations dict from ``Base``, not ``Derived``."
159
- msgstr "如此会打印出 ``Base`` 的注解字典,而非 ``Derived`` 的。"
159
+ msgstr "会打印出 ``Base`` 的注解字典,而非 ``Derived`` 的。"
160
160
161
161
#: ../../howto/annotations.rst:101
162
162
msgid ""
@@ -167,9 +167,9 @@ msgid ""
167
167
" Since the class may or may not have annotations defined, best practice is "
168
168
"to call the ``get`` method on the class dict."
169
169
msgstr ""
170
- "若要查看的对象是个类( ``isinstance(o, type)``),代码不得不另辟蹊径。这时的最佳做法依赖于 Python 3.9 "
171
- "及之前版本的一处细节:若某个类定义了注解,则会存放于字典 ``__dict__`` 中。由于类不一定会定义注解,最好的做法是在类的 dict 上调用 "
172
- "``get`` 方法。"
170
+ "若待检查的对象是类(即 ``isinstance(o, type)``),代码不得不另辟蹊径。这时的最佳实践依赖于 3.9 及更低版本的 Python "
171
+ "中的一处实现细节:若类定义了注解,则注解会被放入类的 ``__dict__`` 字典。类不一定有注解,故最佳实践是在类的字典上调用 ``get`` "
172
+ "方法。"
173
173
174
174
#: ../../howto/annotations.rst:109
175
175
msgid ""
@@ -328,7 +328,7 @@ msgstr "应避免删除对象的 ``__annotations__`` 属性。"
328
328
329
329
#: ../../howto/annotations.rst:197
330
330
msgid "``__annotations__`` Quirks"
331
- msgstr "``__annotations__`` 的坑 "
331
+ msgstr "``__annotations__`` 的一些“坑” "
332
332
333
333
#: ../../howto/annotations.rst:199
334
334
msgid ""
0 commit comments