@@ -12,7 +12,7 @@ msgid ""
1212msgstr ""
1313"Project-Id-Version : Python 3.11\n "
1414"Report-Msgid-Bugs-To : \n "
15- "POT-Creation-Date : 2023-11-24 16:45 +0000\n "
15+ "POT-Creation-Date : 2023-12-15 16:34 +0000\n "
1616"PO-Revision-Date : 2023-05-24 02:11+0000\n "
1717"
Last-Translator :
Freesand Leo <[email protected] >, 2023\n "
1818"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -259,13 +259,11 @@ msgstr ""
259259
260260#: ../../howto/annotations.rst:155
261261msgid ""
262- "If ``o`` is a callable (but not a class), use `` o.__globals__`` as the "
263- "globals when calling :func:`eval`."
262+ "If ``o`` is a callable (but not a class), use :attr:` o.__globals__ "
263+ "<function.__globals__>` as the globals when calling :func:`eval`."
264264msgstr ""
265- "如果 ``o`` 是个可调用对象(但不是一个类),在调用 :func:`eval` 时,``o.__dict__`` 可视为 ``globals`` "
266- "。"
267265
268- #: ../../howto/annotations.rst:158
266+ #: ../../howto/annotations.rst:159
269267msgid ""
270268"However, not all string values used as annotations can be successfully "
271269"turned into Python values by :func:`eval`. String values could theoretically"
@@ -276,19 +274,19 @@ msgstr ""
276274"但并不是所有注解字符串都可以通过 :func:`eval` 成功地转化为 Python "
277275"值。理论上,注解字符串中可以包含任何合法字符串,确实有一些类型提示的场合,需要用到特殊的 *无法* 被解析的字符串来作注解。比如:"
278276
279- #: ../../howto/annotations.rst:165
277+ #: ../../howto/annotations.rst:166
280278msgid ""
281279":pep:`604` union types using ``|``, before support for this was added to "
282280"Python 3.10."
283281msgstr "在 Python 支持 :pep:`604` 的联合类型 ``|`` (Python 3.10) 之前使用它。"
284282
285- #: ../../howto/annotations.rst:167
283+ #: ../../howto/annotations.rst:168
286284msgid ""
287285"Definitions that aren't needed at runtime, only imported when "
288286":const:`typing.TYPE_CHECKING` is true."
289287msgstr "运行时用不到的定义,只在 :const:`typing.TYPE_CHECKING` 为 True 时才会导入。"
290288
291- #: ../../howto/annotations.rst:170
289+ #: ../../howto/annotations.rst:171
292290msgid ""
293291"If :func:`eval` attempts to evaluate such values, it will fail and raise an "
294292"exception. So, when designing a library API that works with annotations, "
@@ -297,43 +295,43 @@ msgid ""
297295msgstr ""
298296"如果 :func:`eval` 试图求值,将会失败并触发异常。因此,当要设计一个可采用注解的库 API ,建议只在调用方显式请求的时才对字符串求值。"
299297
300- #: ../../howto/annotations.rst:178
298+ #: ../../howto/annotations.rst:179
301299msgid "Best Practices For ``__annotations__`` In Any Python Version"
302300msgstr "任何版本 Python 中使用 ``__annotations__`` 的最佳实践"
303301
304- #: ../../howto/annotations.rst:180
302+ #: ../../howto/annotations.rst:181
305303msgid ""
306304"You should avoid assigning to the ``__annotations__`` member of objects "
307305"directly. Let Python manage setting ``__annotations__``."
308306msgstr "应避免直接给对象的 ``__annotations__`` 成员赋值。请让 Python 来管理 ``__annotations__``。"
309307
310- #: ../../howto/annotations.rst:183
308+ #: ../../howto/annotations.rst:184
311309msgid ""
312310"If you do assign directly to the ``__annotations__`` member of an object, "
313311"you should always set it to a ``dict`` object."
314312msgstr "如果直接给某对象的 ``__annotations__`` 成员赋值,应该确保设成一个 ``dict`` 对象。"
315313
316- #: ../../howto/annotations.rst:186
314+ #: ../../howto/annotations.rst:187
317315msgid ""
318316"If you directly access the ``__annotations__`` member of an object, you "
319317"should ensure that it's a dictionary before attempting to examine its "
320318"contents."
321319msgstr "如果直接访问某个对象的 ``__annotations__`` 成员,在解析其值之前,应先确认其为字典类型。"
322320
323- #: ../../howto/annotations.rst:190
321+ #: ../../howto/annotations.rst:191
324322msgid "You should avoid modifying ``__annotations__`` dicts."
325323msgstr "应避免修改 ``__annotations__`` 字典。"
326324
327- #: ../../howto/annotations.rst:192
325+ #: ../../howto/annotations.rst:193
328326msgid ""
329327"You should avoid deleting the ``__annotations__`` attribute of an object."
330328msgstr "应避免删除对象的 ``__annotations__`` 属性。"
331329
332- #: ../../howto/annotations.rst:197
330+ #: ../../howto/annotations.rst:198
333331msgid "``__annotations__`` Quirks"
334332msgstr "``__annotations__`` 的坑"
335333
336- #: ../../howto/annotations.rst:199
334+ #: ../../howto/annotations.rst:200
337335msgid ""
338336"In all versions of Python 3, function objects lazy-create an annotations "
339337"dict if no annotations are defined on that object. You can delete the "
@@ -350,13 +348,13 @@ msgstr ""
350348"``AttributeError`` 异常;连续两次调用 ``del fn.__annotations__`` 一定会抛出一次 "
351349"``AttributeError`` 异常。"
352350
353- #: ../../howto/annotations.rst:209
351+ #: ../../howto/annotations.rst:210
354352msgid ""
355353"Everything in the above paragraph also applies to class and module objects "
356354"in Python 3.10 and newer."
357355msgstr "以上同样适用于 Python 3.10 以上版本中的类和模块对象。"
358356
359- #: ../../howto/annotations.rst:212
357+ #: ../../howto/annotations.rst:213
360358msgid ""
361359"In all versions of Python 3, you can set ``__annotations__`` on a function "
362360"object to ``None``. However, subsequently accessing the annotations on that"
@@ -370,7 +368,7 @@ msgstr ""
370368"``fn.__annotations__`` 访问该对象的注解时,会像本节第一段所述那样,直接创建一个空字典。但在任何 Python "
371369"版本中,模块和类均非如此,他们允许将 ``__annotations__`` 设为任意 Python 值,并且会留存所设值。"
372370
373- #: ../../howto/annotations.rst:220
371+ #: ../../howto/annotations.rst:221
374372msgid ""
375373"If Python stringizes your annotations for you (using ``from __future__ "
376374"import annotations``), and you specify a string as an annotation, the string"
@@ -380,7 +378,7 @@ msgstr ""
380378"如果 Python 会对注解作字符串化处理(用 ``from __future__ import annotations`` "
381379"),并且注解本身就是一个字符串,那么将会为其加上引号。实际效果就是,注解加了 *两次* 引号。例如:"
382380
383- #: ../../howto/annotations.rst:231
381+ #: ../../howto/annotations.rst:232
384382msgid ""
385383"This prints ``{'a': \" 'str'\" }``. This shouldn't really be considered a "
386384"\" quirk\" ; it's mentioned here simply because it might be surprising."
0 commit comments