@@ -2474,13 +2474,15 @@ msgstr ""
24742474
24752475#: ../../faq/programming.rst:1745
24762476msgid "When can I rely on identity tests with the *is* operator?"
2477- msgstr ""
2477+ msgstr "いつ *is* 演算子での同一性テストが頼れますか? "
24782478
24792479#: ../../faq/programming.rst:1747
24802480msgid ""
24812481"The ``is`` operator tests for object identity. The test ``a is b`` is "
24822482"equivalent to ``id(a) == id(b)``."
24832483msgstr ""
2484+ "``is`` 演算子はオブジェクトの同一性をテストします。 テスト ``a is b`` は "
2485+ "``id(a) == id(b)`` と同等です。"
24842486
24852487#: ../../faq/programming.rst:1750
24862488msgid ""
@@ -2489,33 +2491,48 @@ msgid ""
24892491"usually faster than equality tests. And unlike equality tests, identity "
24902492"tests are guaranteed to return a boolean ``True`` or ``False``."
24912493msgstr ""
2494+ "同一性テストの最も重要な特性は、オブジェクトは常にそれ自身と同一であり、 ``a "
2495+ "is a`` は常に ``True`` を返すということです。 同一性テストは通常、等価性テス"
2496+ "トよりも高速です。 また、等価性テストとは異なり、同一性テストは真偽値 "
2497+ "``True`` または``False`` を返すことが保証されています。"
24922498
24932499#: ../../faq/programming.rst:1755
24942500msgid ""
24952501"However, identity tests can *only* be substituted for equality tests when "
24962502"object identity is assured. Generally, there are three circumstances where "
24972503"identity is guaranteed:"
24982504msgstr ""
2505+ "ただし、同一性テストを等価性テストの代用とできるのは、オブジェクトの同一性が"
2506+ "保証されている場合 *のみ* です。 一般的に、同一性が保証される状況は3つありま"
2507+ "す:"
24992508
25002509#: ../../faq/programming.rst:1759
25012510msgid ""
25022511"1) Assignments create new names but do not change object identity. After "
25032512"the assignment ``new = old``, it is guaranteed that ``new is old``."
25042513msgstr ""
2514+ "1) 代入は新しい名前を作りますが、オブジェクトIDは変えません。 ``new = old`` "
2515+ "代入の後、 ``new is old`` が保証されます。"
25052516
25062517#: ../../faq/programming.rst:1762
25072518msgid ""
25082519"2) Putting an object in a container that stores object references does not "
25092520"change object identity. After the list assignment ``s[0] = x``, it is "
25102521"guaranteed that ``s[0] is x``."
25112522msgstr ""
2523+ "2) オブジェクト参照を格納するコンテナにオブジェクトを入れても、オブジェクトID"
2524+ "は変わりません。 ``s[0] = x`` リスト代入の後、 ``s[0] is x`` が保証されま"
2525+ "す。"
25122526
25132527#: ../../faq/programming.rst:1766
25142528msgid ""
25152529"3) If an object is a singleton, it means that only one instance of that "
25162530"object can exist. After the assignments ``a = None`` and ``b = None``, it "
25172531"is guaranteed that ``a is b`` because ``None`` is a singleton."
25182532msgstr ""
2533+ "3) オブジェクトがシングルトンなら、それはそのオブジェクトのインスタンスは1つ"
2534+ "だけ存在できることを意味します。 ``a = None`` と ``b = None`` 代入の後、 "
2535+ "``a is b`` が保証されます。``None`` がシングルトンのためです。"
25192536
25202537#: ../../faq/programming.rst:1770
25212538msgid ""
@@ -2524,16 +2541,22 @@ msgid ""
25242541"check constants such as :class:`int` and :class:`str` which aren't "
25252542"guaranteed to be singletons::"
25262543msgstr ""
2544+ "多くの他の状況では、同一性テストは賢明でなく、透過性テストをお勧めします。 "
2545+ "特に、シングルトンであることが保証されていない :class:`int` や :class:`str` "
2546+ "などの定数をチェックするために同一性テストを使わないでください。"
25272547
25282548#: ../../faq/programming.rst:1787
25292549msgid "Likewise, new instances of mutable containers are never identical::"
25302550msgstr ""
2551+ "同様に、ミュータブルなコンテナの新しいインスタンスは同一ではありません::"
25312552
25322553#: ../../faq/programming.rst:1794
25332554msgid ""
25342555"In the standard library code, you will see several common patterns for "
25352556"correctly using identity tests:"
25362557msgstr ""
2558+ "標準ライブラリのコードには、同一性テストを正しく使うための一般的なパターンが"
2559+ "あります:"
25372560
25382561#: ../../faq/programming.rst:1797
25392562msgid ""
@@ -2542,6 +2565,9 @@ msgid ""
25422565"confusion with other objects that may have boolean values that evaluate to "
25432566"false."
25442567msgstr ""
2568+ "1) :pep:`8` で推奨されるように、同一性テストは ``None`` のチェックの良い方法"
2569+ "です。 コードの中で平易な英語のように読めますし、 false と評価される真偽値を"
2570+ "持ちうる他のオブジェクトとの混同を避けます。"
25452571
25462572#: ../../faq/programming.rst:1801
25472573msgid ""
@@ -2557,6 +2583,9 @@ msgid ""
25572583"identity tests. This prevents the code from being confused by objects such "
25582584"as ``float('NaN')`` that are not equal to themselves."
25592585msgstr ""
2586+ "3) コンテナの実装では、等価性テストを同一性テストで補強しないといけない場合が"
2587+ "あります。 これは、 ``float('NaN')`` のような自分自身と等価でないオブジェク"
2588+ "トによってコードが混乱するのを防ぐためです。"
25602589
25612590#: ../../faq/programming.rst:1821
25622591msgid ""
0 commit comments