1111# Siyuan Xu <[email protected] >, 20191212# Meng Du <[email protected] >, 20191313# ppcfish <[email protected] >, 201914- # Freesand Leo <[email protected] >, 2020 14+ # Freesand Leo <[email protected] >, 2021 1515#
1616#, fuzzy
1717msgid ""
@@ -20,7 +20,7 @@ msgstr ""
2020"Report-Msgid-Bugs-To : \n "
2121"POT-Creation-Date : 2021-04-04 05:56+0000\n "
2222"PO-Revision-Date : 2017-02-16 17:43+0000\n "
23- "
Last-Translator :
Freesand Leo <[email protected] >, 2020 \n "
23+ "
Last-Translator :
Freesand Leo <[email protected] >, 2021 \n "
2424"Language-Team : Chinese (China) (https://www.transifex.com/python-doc/teams/5390/zh_CN/)\n "
2525"MIME-Version : 1.0\n "
2626"Content-Type : text/plain; charset=UTF-8\n "
@@ -2085,13 +2085,13 @@ msgstr ""
20852085
20862086#: ../../faq/programming.rst:1706
20872087msgid "When can I rely on identity tests with the *is* operator?"
2088- msgstr ""
2088+ msgstr "我可以在在何时通过 *is* 运算符进行标识号检测? "
20892089
20902090#: ../../faq/programming.rst:1708
20912091msgid ""
20922092"The ``is`` operator tests for object identity. The test ``a is b`` is "
20932093"equivalent to ``id(a) == id(b)``."
2094- msgstr ""
2094+ msgstr "``is`` 运算符可检测对象的标识号。 检测 ``a is b`` 等价于 ``id(a) == id(b)``。 "
20952095
20962096#: ../../faq/programming.rst:1711
20972097msgid ""
@@ -2100,33 +2100,38 @@ msgid ""
21002100" usually faster than equality tests. And unlike equality tests, identity "
21012101"tests are guaranteed to return a boolean ``True`` or ``False``."
21022102msgstr ""
2103+ "标识号检测最重要的特性是一个对象自身的标识号总是相同,``a is a`` 总是返回 ``True``。 标识号检测通常比相等性检测更快。 "
2104+ "并且不同于相等性检测,标识号检测会保证返回一个布尔值 ``True`` 或 ``False``。"
21032105
21042106#: ../../faq/programming.rst:1716
21052107msgid ""
21062108"However, identity tests can *only* be substituted for equality tests when "
21072109"object identity is assured. Generally, there are three circumstances where "
21082110"identity is guaranteed:"
2109- msgstr ""
2111+ msgstr "但是,标识号检测 *只能* 在确定对象标识的场景下替代相等性检测。 一般来说,在以下三种情况下对象标识是确定的: "
21102112
21112113#: ../../faq/programming.rst:1720
21122114msgid ""
21132115"1) Assignments create new names but do not change object identity. After "
21142116"the assignment ``new = old``, it is guaranteed that ``new is old``."
2115- msgstr ""
2117+ msgstr "1) 赋值创建了新的名称但没有改变对象标识。 在赋值操作 ``new = old`` 之后,可以保证 ``new is old``。 "
21162118
21172119#: ../../faq/programming.rst:1723
21182120msgid ""
21192121"2) Putting an object in a container that stores object references does not "
21202122"change object identity. After the list assignment ``s[0] = x``, it is "
21212123"guaranteed that ``s[0] is x``."
21222124msgstr ""
2125+ "2) 将一个对象放入存储对象引用的容器不会改变对象标识。 在列表赋值操作 ``s[0] = x`` 之后,可以保证 ``s[0] is x``。"
21232126
21242127#: ../../faq/programming.rst:1727
21252128msgid ""
21262129"3) If an object is a singleton, it means that only one instance of that "
21272130"object can exist. After the assignments ``a = None`` and ``b = None``, it "
21282131"is guaranteed that ``a is b`` because ``None`` is a singleton."
21292132msgstr ""
2133+ "3) 如果对象是一个单例,意味着该对象只能存在一个实例。 在赋值操作 ``a = None`` 和 ``b = None`` 之后,可以保证 ``a "
2134+ "is b``,因为 ``None`` 是单例对象。"
21302135
21312136#: ../../faq/programming.rst:1731
21322137msgid ""
@@ -2135,16 +2140,18 @@ msgid ""
21352140"check constants such as :class:`int` and :class:`str` which aren't "
21362141"guaranteed to be singletons::"
21372142msgstr ""
2143+ "在其他大多数情况下,都不建议使用标识号检测而应使用相等性检测。 特别地,标识号检测不应被用于检测常量值例如 :class:`int` 和 "
2144+ ":class:`str`,因为它们并不保证是单例对象::"
21382145
21392146#: ../../faq/programming.rst:1748
21402147msgid "Likewise, new instances of mutable containers are never identical::"
2141- msgstr ""
2148+ msgstr "同样地,可变容器的新实例标识号一定不会相同:: "
21422149
21432150#: ../../faq/programming.rst:1755
21442151msgid ""
21452152"In the standard library code, you will see several common patterns for "
21462153"correctly using identity tests:"
2147- msgstr ""
2154+ msgstr "在标准库代码中,你将看到一些正确使用标识号检测的常见范式: "
21482155
21492156#: ../../faq/programming.rst:1758
21502157msgid ""
@@ -2153,6 +2160,8 @@ msgid ""
21532160"confusion with other objects that may have boolean values that evaluate to "
21542161"false."
21552162msgstr ""
2163+ "1) 如 :pep:`8` 所推荐的,标识号检测是 ``None`` 值检测的推荐方式。 "
2164+ "在代码中这样的写法看起来像是自然的英文并可以避免与其他可能具有会被解析为假值的布尔值的对象相混淆。"
21562165
21572166#: ../../faq/programming.rst:1762
21582167msgid ""
0 commit comments