@@ -85,8 +85,8 @@ msgid ""
8585"any object that supports annotations. This function can also \" un-"
8686"stringize\" stringized annotations for you."
8787msgstr ""
88- "Python 3.10 在标准库中加入了一个新函数::func:`inspect.get_annotations`。在 Python 3.10 "
89- "以上的版本中,调用该函数就是访问对象注解字典的最佳做法。该函数还可以 “解析”字符串形式的注解 。"
88+ "Python 3.10 在标准库中加入了一个新函数::func:`inspect.get_annotations`。在 3.10 及更高版本的 "
89+ "Python 中,调用该函数就是访问任何支持注解的对象的注解字典的最佳实践。该函数还可以为你 “解析”字符串化了的注解 。"
9090
9191#: ../../howto/annotations.rst:42
9292msgid ""
@@ -98,10 +98,10 @@ msgid ""
9898"of these three *specific* objects, you may simply use ``o.__annotations__`` "
9999"to get at the object's annotations dict."
100100msgstr ""
101- "有时会因为某些原因看不到 :func:`inspect.get_annotations` ,也可以直接访问 ``__annotations__`` "
102- "数据成员。这方面的最佳实践在 Python 3.10 中也发生了变化:从 Python 3.10 开始,Python 函数、类和模块的 "
103- "``o.__annotations__`` *保证* 可用。如果确定是要查看这三种对象,只要利用 ``o.__annotations__`` "
104- "读取对象的注释字典即可 。"
101+ "不用 :func:`inspect.get_annotations` 也可以手动访问 ``__annotations__`` "
102+ "这一数据成员。该方法的最佳实践在 Python 3.10 中也发生了变化:从 Python 3.10 开始,对于 Python "
103+ "函数、类和模块, ``o.__annotations__`` *保证* 会正常工作。只要你确信所检查的对象是这三种之一,你便可以用 "
104+ "``o.__annotations__`` 获取该对象的注解字典 。"
105105
106106#: ../../howto/annotations.rst:52
107107msgid ""
@@ -112,9 +112,9 @@ msgid ""
112112":func:`getattr` with three arguments, for example ``getattr(o, "
113113"'__annotations__', None)``."
114114msgstr ""
115- "不过其他类型的可调用对象可能就没有定义 ``__annotations__`` 属性,比如由 :func:`functools.partial` "
116- "创建的可调用对象。当访问某个未知对象的 ``__annotations__`` 时,Python 3.10 以上版本的最佳做法是带三个参数去调用 "
117- ":func:`getattr` ,比如 ``getattr(o, '__annotations__', None)``。"
115+ "不过,其它类型的可调用对象可不一定定义了 ``__annotations__`` 属性,就比如说, :func:`functools.partial` "
116+ "创建的可调用对象。当访问某个未知对象的 ``__annotations__`` 时,3.10 及更高版本的 Python 中的最佳实践是用三个参数去调用 "
117+ " :func:`getattr`,类似 ``getattr(o, '__annotations__', None)`` 这样 。"
118118
119119#: ../../howto/annotations.rst:60
120120msgid ""
@@ -123,8 +123,8 @@ msgid ""
123123"parent's ``__annotations__``. In Python 3.10 and newer, the child class's "
124124"annotations will be an empty dict instead."
125125msgstr ""
126- "在 Python 3.10 之前,在一个未定义标注但具有定义了标注的父类的类上访问 ``__annotations__`` 将返回父类的 "
127- "``__annotations__``。 在 Python 3.10 和更新的版本中,子类的标注将改为一个空字典 。"
126+ "Python 3.10 之前,在一个没定义注解而父类定义了注解的类上访问 ``__annotations__`` 将返回父类的 "
127+ "``__annotations__``。在 3.10 及更高版本的 Python 中,这样的子类的标注是一个空字典 。"
128128
129129#: ../../howto/annotations.rst:68
130130msgid "Accessing The Annotations Dict Of An Object In Python 3.9 And Older"
@@ -135,8 +135,7 @@ msgid ""
135135"In Python 3.9 and older, accessing the annotations dict of an object is much"
136136" more complicated than in newer versions. The problem is a design flaw in "
137137"these older versions of Python, specifically to do with class annotations."
138- msgstr ""
139- "在 Python 3.9 及之前的版本中,访问对象的注解字典要比新版本中复杂得多。这个是 Python 低版本的一个设计缺陷,特别是访问类的注解时。"
138+ msgstr "在 3.9 及更低版本的 Python 中访问对象的注解字典要比新版复杂。这是低版本 Python 的设计缺陷,特别是类的注解。"
140139
141140#: ../../howto/annotations.rst:75
142141msgid ""
@@ -146,8 +145,8 @@ msgid ""
146145"should use three-argument :func:`getattr` to access the object's "
147146"``__annotations__`` attribute."
148147msgstr ""
149- "要访问其他对象 ——函数、可调用对象和模块——的注释字典,最佳做法与 3.10 版本相同,假定不想调用 "
150- ":func:`inspect.get_annotations`:你应该用三个参数调用 :func:`getattr` , 以访问对象的 "
148+ "访问其它对象 ——函数、其它可调用对象和模块——的注解字典的最佳实践与 3.10 版本相同,如果不用 "
149+ ":func:`inspect.get_annotations`,就用三个参数去调用 :func:`getattr` 以访问对象的 "
151150"``__annotations__`` 属性。"
152151
153152#: ../../howto/annotations.rst:82
0 commit comments