@@ -2103,13 +2103,13 @@ msgstr ""
21032103
21042104#: ../../faq/programming.rst:1742
21052105msgid "When can I rely on identity tests with the *is* operator?"
2106- msgstr "什么情况下可以依靠*is*运算符对标识符进行检测 ? "
2106+ msgstr "什么情况下可以依靠*is*运算符进行对象的身份相等性测试 ? "
21072107
21082108#: ../../faq/programming.rst:1744
21092109msgid ""
21102110"The ``is`` operator tests for object identity. The test ``a is b`` is "
21112111"equivalent to ``id(a) == id(b)``."
2112- msgstr "``is`` 运算符可检测对象的标识号。 检测 ``a is b`` 等价于 ``id(a) == id(b)``。"
2112+ msgstr "``is`` 运算符可用于测试对象的身份相等性。 ``a is b`` 等价于 ``id(a) == id(b)``。"
21132113
21142114#: ../../faq/programming.rst:1747
21152115msgid ""
@@ -2118,38 +2118,37 @@ msgid ""
21182118" usually faster than equality tests. And unlike equality tests, identity "
21192119"tests are guaranteed to return a boolean ``True`` or ``False``."
21202120msgstr ""
2121- "标识号检测最重要的特性是一个对象自身的标识号总是相同 ,``a is a`` 总是返回 ``True``。 标识号检测通常比相等性检测更快。 "
2122- "并且不同于相等性检测,标识号检测会保证返回一个布尔值 ``True`` 或 ``False``。"
2121+ "身份相等性最重要的特性就是对象总是等同于自身 ,``a is a`` "
2122+ "一定返回``True``。身份相等性测试的速度通常比相等性测试要快。而且与相等性测试不一样,身份相等性测试会确保返回布尔值 ``True``或 ``False``。"
21232123
21242124#: ../../faq/programming.rst:1752
21252125msgid ""
21262126"However, identity tests can *only* be substituted for equality tests when "
21272127"object identity is assured. Generally, there are three circumstances where "
21282128"identity is guaranteed:"
2129- msgstr "但是,标识号检测 *只能* 在确定对象标识的场景下替代相等性检测。 一般来说,在以下三种情况下对象标识是确定的: "
2129+ msgstr "但是,身份相等性测试 *只能*在对象身份确定的场景下才可替代相等性测试。 一般来说,有以下3种情况对象身份是可以确定的: "
21302130
21312131#: ../../faq/programming.rst:1756
21322132msgid ""
21332133"1) Assignments create new names but do not change object identity. After "
21342134"the assignment ``new = old``, it is guaranteed that ``new is old``."
2135- msgstr "1) 赋值创建了新的名称但没有改变对象标识。 在赋值操作 ``new = old`` 之后,可以保证 ``new is old``。"
2135+ msgstr "1) 赋值操作创建了新的名称但没有改变对象身份。 在赋值操作``new = old``之后,可以保证``new is old``。"
21362136
21372137#: ../../faq/programming.rst:1759
21382138msgid ""
21392139"2) Putting an object in a container that stores object references does not "
21402140"change object identity. After the list assignment ``s[0] = x``, it is "
21412141"guaranteed that ``s[0] is x``."
2142- msgstr ""
2143- "2) 将一个对象放入存储对象引用的容器不会改变对象标识。 在列表赋值操作 ``s[0] = x`` 之后,可以保证 ``s[0] is x``。"
2142+ msgstr "2) 将对象置入存放对象引用的容器,对象身份不会改变。在列表赋值操作``s[0] = x``之后,可以保证 ``s[0] is x``。"
21442143
21452144#: ../../faq/programming.rst:1763
21462145msgid ""
21472146"3) If an object is a singleton, it means that only one instance of that "
21482147"object can exist. After the assignments ``a = None`` and ``b = None``, it "
21492148"is guaranteed that ``a is b`` because ``None`` is a singleton."
21502149msgstr ""
2151- "3) 如果对象是一个单例,意味着该对象只能存在一个实例。 在赋值操作 ``a = None`` 和 ``b = None`` 之后,可以保证 ``a "
2152- "is b``,因为 ``None`` 是单例对象。"
2150+ "3) 单例对象,也即该对象只能存在一个实例。 在赋值操作``a = None``和 ``b = None`` 之后,可以保证 ``a is "
2151+ "b``,因为``None``是单例对象。"
21532152
21542153#: ../../faq/programming.rst:1767
21552154msgid ""
@@ -2158,18 +2157,18 @@ msgid ""
21582157"check constants such as :class:`int` and :class:`str` which aren't "
21592158"guaranteed to be singletons::"
21602159msgstr ""
2161- "在其他大多数情况下,都不建议使用标识号检测而应使用相等性检测。 特别地,标识号检测不应被用于检测常量值例如 :class:`int` 和 "
2162- ":class:`str`,因为它们并不保证是单例对象:: "
2160+ "其他大多数情况下,都不建议使用身份相等性测试,而应采用相等性测试。尤其是不应将身份相等性测试用于检测常量值,例如 :class:`int` 和 "
2161+ ":class:`str`,因为他们并不一定是单例对象: "
21632162
21642163#: ../../faq/programming.rst:1784
21652164msgid "Likewise, new instances of mutable containers are never identical::"
2166- msgstr "同样地,可变容器的新实例标识号一定不会相同:: "
2165+ msgstr "同样地,可变容器的新实例,对象身份一定不同: "
21672166
21682167#: ../../faq/programming.rst:1791
21692168msgid ""
21702169"In the standard library code, you will see several common patterns for "
21712170"correctly using identity tests:"
2172- msgstr "在标准库代码中,你将看到一些正确使用标识号检测的常见范式: "
2171+ msgstr "在标准库代码中,给出了一些正确使用对象身份测试的常见模式: "
21732172
21742173#: ../../faq/programming.rst:1794
21752174msgid ""
@@ -2178,8 +2177,9 @@ msgid ""
21782177"confusion with other objects that may have boolean values that evaluate to "
21792178"false."
21802179msgstr ""
2181- "1) 如 :pep:`8` 所推荐的,标识号检测是 ``None`` 值检测的推荐方式。 "
2182- "在代码中这样的写法看起来像是自然的英文并可以避免与其他可能具有会被解析为假值的布尔值的对象相混淆。"
2180+ "1) 正如 :pep:`8` "
2181+ "所推荐的,对象身份测试是``None``值的推荐检测方式。这样的代码读起来就像自然的英文,并可以避免与其他可能为布尔值且计算结果为 False "
2182+ "的对象相混淆。"
21832183
21842184#: ../../faq/programming.rst:1798
21852185msgid ""
0 commit comments