1
1
# SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) 2001-2023 , Python Software Foundation
2
+ # Copyright (C) 2001-2024 , Python Software Foundation
3
3
# This file is distributed under the same license as the Python package.
4
4
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
5
#
6
6
# Translators:
7
- # Rafael Fontenelle <[email protected] >, 2023
8
- # Freesand Leo <[email protected] >, 2023
7
+ # Rafael Fontenelle <[email protected] >, 2024
9
8
#
10
9
#, fuzzy
11
10
msgid ""
12
11
msgstr ""
13
12
"Project-Id-Version : Python 3.10\n "
14
13
"Report-Msgid-Bugs-To : \n "
15
- "POT-Creation-Date : 2023-11-24 18:59 +0000\n "
14
+ "POT-Creation-Date : 2024-03-22 19:02 +0000\n "
16
15
"PO-Revision-Date : 2022-11-05 17:21+0000\n "
17
- "Last-Translator : Freesand Leo <yuqinju@163 .com>, 2023 \n "
16
+ "Last-Translator : Rafael Fontenelle <rffontenelle@gmail .com>, 2024 \n "
18
17
"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
19
18
"MIME-Version : 1.0\n "
20
19
"Content-Type : text/plain; charset=UTF-8\n "
@@ -24,7 +23,7 @@ msgstr ""
24
23
25
24
#: ../../howto/annotations.rst:5
26
25
msgid "Annotations Best Practices"
27
- msgstr "对象注解属性的最佳实践 "
26
+ msgstr "注解最佳实践 "
28
27
29
28
#: ../../howto/annotations.rst:0
30
29
msgid "author"
@@ -44,9 +43,7 @@ msgid ""
44
43
" annotations dicts. If you write Python code that examines "
45
44
"``__annotations__`` on Python objects, we encourage you to follow the "
46
45
"guidelines described below."
47
- msgstr ""
48
- "本文意在汇聚对象的注解字典用法的最佳实践。 如果 Python 代码会去查看 Python 对象的 ``__annotations__`` "
49
- "属性,建议遵循以下准则。"
46
+ msgstr "本文档旨在概括与注解字典打交道的最佳实践。查看 Python 对象的 ``__annotations__`` 的代码应遵循下述准则。"
50
47
51
48
#: ../../howto/annotations.rst:16
52
49
msgid ""
@@ -56,8 +53,9 @@ msgid ""
56
53
"and older, other best practices for ``__annotations__`` that apply to any "
57
54
"Python version, and quirks of ``__annotations__``."
58
55
msgstr ""
59
- "本文分为四个部分:在 Python 3.10 以上版本中访问对象注解的最佳实践、在Python 3.9 以上版本中访问对象注解的最佳实践、适用于任何 "
60
- "Python 版本的其他 ``__annotations__`` 最佳实践、``__annotations__`` 的特别之处。"
56
+ "本文档按四部分组织:在 3.10 及更高版本的 Python 中查看对象注解的最佳实践、在 3.9 及更低版本的 Python "
57
+ "中查看对象注解的最佳实践、其它一些适于任何版本的 Python 的 ``__annotations__`` "
58
+ "的最佳实践、``__annotations__`` 的一些“坑”。"
61
59
62
60
#: ../../howto/annotations.rst:26
63
61
msgid ""
@@ -66,12 +64,12 @@ msgid ""
66
64
"information on how to use \" type hints\" in your code, please see the "
67
65
":mod:`typing` module."
68
66
msgstr ""
69
- "请注意,本文是专门介绍 ``__annotations__`` 的,而不是介绍注解的用法。若要了解 “类型提示”的使用信息 ,请参阅 "
67
+ "本文是 ``__annotations__`` 的文档,不是介绍注解用法的文档。如果要查找关于如何使用 “类型提示”的信息 ,请参阅 "
70
68
":mod:`typing` 模块。"
71
69
72
70
#: ../../howto/annotations.rst:33
73
71
msgid "Accessing The Annotations Dict Of An Object In Python 3.10 And Newer"
74
- msgstr "在 Python 3.10 以上版本中访问对象的注解字典 "
72
+ msgstr "在 3.10 及更高版本的 Python 中访问对象的注解字典 "
75
73
76
74
#: ../../howto/annotations.rst:35
77
75
msgid ""
@@ -81,8 +79,8 @@ msgid ""
81
79
"any object that supports annotations. This function can also \" un-"
82
80
"stringize\" stringized annotations for you."
83
81
msgstr ""
84
- "Python 3.10 在标准库中加入了一个新函数::func:`inspect.get_annotations`。在 Python 3.10 "
85
- "以上的版本中,调用该函数就是访问对象注解字典的最佳做法。该函数还可以 “解析”字符串形式的注解 。"
82
+ "Python 3.10 在标准库中加入了一个新函数::func:`inspect.get_annotations`。在 3.10 及更高版本的 "
83
+ "Python 中,调用该函数就是访问任何支持注解的对象的注解字典的最佳实践。该函数还可以为你 “解析”字符串化了的注解 。"
86
84
87
85
#: ../../howto/annotations.rst:42
88
86
msgid ""
@@ -94,10 +92,10 @@ msgid ""
94
92
"of these three *specific* objects, you may simply use ``o.__annotations__`` "
95
93
"to get at the object's annotations dict."
96
94
msgstr ""
97
- "有时会因为某些原因看不到 :func:`inspect.get_annotations` ,也可以直接访问 ``__annotations__`` "
98
- "数据成员。这方面的最佳实践在 Python 3.10 中也发生了变化:从 Python 3.10 开始,Python 函数、类和模块的 "
99
- "``o.__annotations__`` *保证* 可用。如果确定是要查看这三种对象,只要利用 ``o.__annotations__`` "
100
- "读取对象的注释字典即可 。"
95
+ "不用 :func:`inspect.get_annotations` 也可以手动访问 ``__annotations__`` "
96
+ "这一数据成员。该方法的最佳实践在 Python 3.10 中也发生了变化:从 Python 3.10 开始,对于 Python "
97
+ "函数、类和模块, ``o.__annotations__`` *保证* 会正常工作。只要你确信所检查的对象是这三种之一,你便可以用 "
98
+ "``o.__annotations__`` 获取该对象的注解字典 。"
101
99
102
100
#: ../../howto/annotations.rst:52
103
101
msgid ""
@@ -108,9 +106,9 @@ msgid ""
108
106
":func:`getattr` with three arguments, for example ``getattr(o, "
109
107
"'__annotations__', None)``."
110
108
msgstr ""
111
- "不过其他类型的可调用对象可能就没有定义 ``__annotations__`` 属性,比如由 :func:`functools.partial` "
112
- "创建的可调用对象。当访问某个未知对象的 ``__annotations__`` 时,Python 3.10 以上版本的最佳做法是带三个参数去调用 "
113
- ":func:`getattr` ,比如 ``getattr(o, '__annotations__', None)``。"
109
+ "不过,其它类型的可调用对象可不一定定义了 ``__annotations__`` 属性,就比如说, :func:`functools.partial` "
110
+ "创建的可调用对象。当访问某个未知对象的 ``__annotations__`` 时,3.10 及更高版本的 Python 中的最佳实践是用三个参数去调用 "
111
+ " :func:`getattr`,类似 ``getattr(o, '__annotations__', None)`` 这样 。"
114
112
115
113
#: ../../howto/annotations.rst:60
116
114
msgid ""
@@ -119,20 +117,19 @@ msgid ""
119
117
"parent's ``__annotations__``. In Python 3.10 and newer, the child class's "
120
118
"annotations will be an empty dict instead."
121
119
msgstr ""
122
- "在 Python 3.10 之前,在一个未定义标注但具有定义了标注的父类的类上访问 ``__annotations__`` 将返回父类的 "
123
- "``__annotations__``。 在 Python 3.10 和更新的版本中,子类的标注将改为一个空字典 。"
120
+ "Python 3.10 之前,在一个没定义注解而父类定义了注解的类上访问 ``__annotations__`` 将返回父类的 "
121
+ "``__annotations__``。在 3.10 及更高版本的 Python 中,这样的子类的标注是一个空字典 。"
124
122
125
123
#: ../../howto/annotations.rst:68
126
124
msgid "Accessing The Annotations Dict Of An Object In Python 3.9 And Older"
127
- msgstr "在 Python 3.9 及更早的版本中访问对象的注解字典 "
125
+ msgstr "在 3.9 及更低版本的 Python 中访问对象的注解字典 "
128
126
129
127
#: ../../howto/annotations.rst:70
130
128
msgid ""
131
129
"In Python 3.9 and older, accessing the annotations dict of an object is much"
132
130
" more complicated than in newer versions. The problem is a design flaw in "
133
131
"these older versions of Python, specifically to do with class annotations."
134
- msgstr ""
135
- "在 Python 3.9 及之前的版本中,访问对象的注解字典要比新版本中复杂得多。这个是 Python 低版本的一个设计缺陷,特别是访问类的注解时。"
132
+ msgstr "在 3.9 及更低版本的 Python 中访问对象的注解字典要比新版复杂。这是低版本 Python 的设计缺陷,特别是类的注解。"
136
133
137
134
#: ../../howto/annotations.rst:75
138
135
msgid ""
@@ -142,8 +139,8 @@ msgid ""
142
139
"should use three-argument :func:`getattr` to access the object's "
143
140
"``__annotations__`` attribute."
144
141
msgstr ""
145
- "要访问其他对象 ——函数、可调用对象和模块——的注释字典,最佳做法与 3.10 版本相同,假定不想调用 "
146
- ":func:`inspect.get_annotations`:你应该用三个参数调用 :func:`getattr` , 以访问对象的 "
142
+ "访问其它对象 ——函数、其它可调用对象和模块——的注解字典的最佳实践与 3.10 版本相同,如果不用 "
143
+ ":func:`inspect.get_annotations`,就用三个参数去调用 :func:`getattr` 以访问对象的 "
147
144
"``__annotations__`` 属性。"
148
145
149
146
#: ../../howto/annotations.rst:82
0 commit comments