11# SOME DESCRIPTIVE TITLE.
2- # Copyright (C) 2001-2023 , Python Software Foundation
2+ # Copyright (C) 2001-2024 , Python Software Foundation
33# This file is distributed under the same license as the Python package.
44# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
55#
66# Translators:
7- # Freesand Leo <[email protected] >, 20238- # Rafael Fontenelle <[email protected] >, 20237+ # Rafael Fontenelle <[email protected] >, 202498#
109#, fuzzy
1110msgid ""
1211msgstr ""
1312"Project-Id-Version : Python 3.11\n "
1413"Report-Msgid-Bugs-To : \n "
15- "POT-Creation-Date : 2023-12-23 00:32 +0000\n "
14+ "POT-Creation-Date : 2024-03-22 16:49 +0000\n "
1615"PO-Revision-Date : 2023-05-24 02:11+0000\n "
17- "
Last-Translator :
Rafael Fontenelle <[email protected] >, 2023 \n "
16+ "
Last-Translator :
Rafael Fontenelle <[email protected] >, 2024 \n "
1817"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
1918"MIME-Version : 1.0\n "
2019"Content-Type : text/plain; charset=UTF-8\n "
@@ -24,7 +23,7 @@ msgstr ""
2423
2524#: ../../howto/annotations.rst:5
2625msgid "Annotations Best Practices"
27- msgstr "对象注解属性的最佳实践 "
26+ msgstr "注解最佳实践 "
2827
2928#: ../../howto/annotations.rst:0
3029msgid "author"
@@ -34,7 +33,7 @@ msgstr "作者"
3433msgid "Larry Hastings"
3534msgstr "Larry Hastings"
3635
37- #: ../../howto/annotations.rstNone
36+ #: ../../howto/annotations.rst-1
3837msgid "Abstract"
3938msgstr "摘要"
4039
@@ -44,9 +43,7 @@ msgid ""
4443" annotations dicts. If you write Python code that examines "
4544"``__annotations__`` on Python objects, we encourage you to follow the "
4645"guidelines described below."
47- msgstr ""
48- "本文意在汇聚对象的注解字典用法的最佳实践。 如果 Python 代码会去查看 Python 对象的 ``__annotations__`` "
49- "属性,建议遵循以下准则。"
46+ msgstr "本文档旨在概括与注解字典打交道的最佳实践。查看 Python 对象的 ``__annotations__`` 的代码应遵循下述准则。"
5047
5148#: ../../howto/annotations.rst:16
5249msgid ""
@@ -56,8 +53,9 @@ msgid ""
5653"and older, other best practices for ``__annotations__`` that apply to any "
5754"Python version, and quirks of ``__annotations__``."
5855msgstr ""
59- "本文分为四个部分:在 Python 3.10 以上版本中访问对象注解的最佳实践、在Python 3.9 以上版本中访问对象注解的最佳实践、适用于任何 "
60- "Python 版本的其他 ``__annotations__`` 最佳实践、``__annotations__`` 的特别之处。"
56+ "本文档按四部分组织:在 3.10 及更高版本的 Python 中查看对象注解的最佳实践、在 3.9 及更低版本的 Python "
57+ "中查看对象注解的最佳实践、其它一些适于任何版本的 Python 的 ``__annotations__`` "
58+ "的最佳实践、``__annotations__`` 的一些“坑”。"
6159
6260#: ../../howto/annotations.rst:26
6361msgid ""
@@ -66,12 +64,12 @@ msgid ""
6664"information on how to use \" type hints\" in your code, please see the "
6765":mod:`typing` module."
6866msgstr ""
69- "请注意,本文是专门介绍 ``__annotations__`` 的,而不是介绍注解的用法。若要了解 “类型提示”的使用信息 ,请参阅 "
67+ "本文是 ``__annotations__`` 的文档,不是介绍注解用法的文档。如果要查找关于如何使用 “类型提示”的信息 ,请参阅 "
7068":mod:`typing` 模块。"
7169
7270#: ../../howto/annotations.rst:33
7371msgid "Accessing The Annotations Dict Of An Object In Python 3.10 And Newer"
74- msgstr "在 Python 3.10 以上版本中访问对象的注解字典 "
72+ msgstr "在 3.10 及更高版本的 Python 中访问对象的注解字典 "
7573
7674#: ../../howto/annotations.rst:35
7775msgid ""
@@ -81,8 +79,8 @@ msgid ""
8179"any object that supports annotations. This function can also \" un-"
8280"stringize\" stringized annotations for you."
8381msgstr ""
84- "Python 3.10 在标准库中加入了一个新函数::func:`inspect.get_annotations`。在 Python 3.10 "
85- "以上的版本中,调用该函数就是访问对象注解字典的最佳做法。该函数还可以 “解析”字符串形式的注解 。"
82+ "Python 3.10 在标准库中加入了一个新函数::func:`inspect.get_annotations`。在 3.10 及更高版本的 "
83+ "Python 中,调用该函数就是访问任何支持注解的对象的注解字典的最佳实践。该函数还可以为你 “解析”字符串化了的注解 。"
8684
8785#: ../../howto/annotations.rst:42
8886msgid ""
@@ -94,10 +92,10 @@ msgid ""
9492"of these three *specific* objects, you may simply use ``o.__annotations__`` "
9593"to get at the object's annotations dict."
9694msgstr ""
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__`` 获取该对象的注解字典 。"
10199
102100#: ../../howto/annotations.rst:52
103101msgid ""
@@ -108,9 +106,9 @@ msgid ""
108106":func:`getattr` with three arguments, for example ``getattr(o, "
109107"'__annotations__', None)``."
110108msgstr ""
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)`` 这样 。"
114112
115113#: ../../howto/annotations.rst:60
116114msgid ""
@@ -119,20 +117,19 @@ msgid ""
119117"parent's ``__annotations__``. In Python 3.10 and newer, the child class's "
120118"annotations will be an empty dict instead."
121119msgstr ""
122- "在 Python 3.10 之前,在一个未定义标注但具有定义了标注的父类的类上访问 ``__annotations__`` 将返回父类的 "
123- "``__annotations__``。 在 Python 3.10 和更新的版本中,子类的标注将改为一个空字典 。"
120+ "Python 3.10 之前,在一个没定义注解而父类定义了注解的类上访问 ``__annotations__`` 将返回父类的 "
121+ "``__annotations__``。在 3.10 及更高版本的 Python 中,这样的子类的标注是一个空字典 。"
124122
125123#: ../../howto/annotations.rst:68
126124msgid "Accessing The Annotations Dict Of An Object In Python 3.9 And Older"
127- msgstr "在 Python 3.9 及更早的版本中访问对象的注解字典 "
125+ msgstr "在 3.9 及更低版本的 Python 中访问对象的注解字典 "
128126
129127#: ../../howto/annotations.rst:70
130128msgid ""
131129"In Python 3.9 and older, accessing the annotations dict of an object is much"
132130" more complicated than in newer versions. The problem is a design flaw in "
133131"these older versions of Python, specifically to do with class annotations."
134- msgstr ""
135- "在 Python 3.9 及之前的版本中,访问对象的注解字典要比新版本中复杂得多。这个是 Python 低版本的一个设计缺陷,特别是访问类的注解时。"
132+ msgstr "在 3.9 及更低版本的 Python 中访问对象的注解字典要比新版复杂。这是低版本 Python 的设计缺陷,特别是类的注解。"
136133
137134#: ../../howto/annotations.rst:75
138135msgid ""
@@ -142,8 +139,8 @@ msgid ""
142139"should use three-argument :func:`getattr` to access the object's "
143140"``__annotations__`` attribute."
144141msgstr ""
145- "要访问其他对象 ——函数、可调用对象和模块——的注释字典,最佳做法与 3.10 版本相同,假定不想调用 "
146- ":func:`inspect.get_annotations`:你应该用三个参数调用 :func:`getattr` , 以访问对象的 "
142+ "访问其它对象 ——函数、其它可调用对象和模块——的注解字典的最佳实践与 3.10 版本相同,如果不用 "
143+ ":func:`inspect.get_annotations`,就用三个参数去调用 :func:`getattr` 以访问对象的 "
147144"``__annotations__`` 属性。"
148145
149146#: ../../howto/annotations.rst:82
0 commit comments