@@ -2557,13 +2557,15 @@ msgstr ""
2557
2557
2558
2558
#: ../../faq/programming.rst:1817
2559
2559
msgid "When can I rely on identity tests with the *is* operator?"
2560
- msgstr ""
2560
+ msgstr "いつ *is* 演算子での同一性テストが頼れますか? "
2561
2561
2562
2562
#: ../../faq/programming.rst:1819
2563
2563
msgid ""
2564
2564
"The ``is`` operator tests for object identity. The test ``a is b`` is "
2565
2565
"equivalent to ``id(a) == id(b)``."
2566
2566
msgstr ""
2567
+ "``is`` 演算子はオブジェクトの同一性をテストします。 テスト ``a is b`` は "
2568
+ "``id(a) == id(b)`` と同等です。"
2567
2569
2568
2570
#: ../../faq/programming.rst:1822
2569
2571
msgid ""
@@ -2572,33 +2574,48 @@ msgid ""
2572
2574
"usually faster than equality tests. And unlike equality tests, identity "
2573
2575
"tests are guaranteed to return a boolean ``True`` or ``False``."
2574
2576
msgstr ""
2577
+ "同一性テストの最も重要な特性は、オブジェクトは常にそれ自身と同一であり、 ``a "
2578
+ "is a`` は常に ``True`` を返すということです。 同一性テストは通常、等価性テス"
2579
+ "トよりも高速です。 また、等価性テストとは異なり、同一性テストは真偽値 "
2580
+ "``True`` または``False`` を返すことが保証されています。"
2575
2581
2576
2582
#: ../../faq/programming.rst:1827
2577
2583
msgid ""
2578
2584
"However, identity tests can *only* be substituted for equality tests when "
2579
2585
"object identity is assured. Generally, there are three circumstances where "
2580
2586
"identity is guaranteed:"
2581
2587
msgstr ""
2588
+ "ただし、同一性テストを等価性テストの代用とできるのは、オブジェクトの同一性が"
2589
+ "保証されている場合 *のみ* です。 一般的に、同一性が保証される状況は3つありま"
2590
+ "す:"
2582
2591
2583
2592
#: ../../faq/programming.rst:1831
2584
2593
msgid ""
2585
2594
"1) Assignments create new names but do not change object identity. After "
2586
2595
"the assignment ``new = old``, it is guaranteed that ``new is old``."
2587
2596
msgstr ""
2597
+ "1) 代入は新しい名前を作りますが、オブジェクトIDは変えません。 ``new = old`` "
2598
+ "代入の後、 ``new is old`` が保証されます。"
2588
2599
2589
2600
#: ../../faq/programming.rst:1834
2590
2601
msgid ""
2591
2602
"2) Putting an object in a container that stores object references does not "
2592
2603
"change object identity. After the list assignment ``s[0] = x``, it is "
2593
2604
"guaranteed that ``s[0] is x``."
2594
2605
msgstr ""
2606
+ "2) オブジェクト参照を格納するコンテナにオブジェクトを入れても、オブジェクトID"
2607
+ "は変わりません。 ``s[0] = x`` リスト代入の後、 ``s[0] is x`` が保証されま"
2608
+ "す。"
2595
2609
2596
2610
#: ../../faq/programming.rst:1838
2597
2611
msgid ""
2598
2612
"3) If an object is a singleton, it means that only one instance of that "
2599
2613
"object can exist. After the assignments ``a = None`` and ``b = None``, it "
2600
2614
"is guaranteed that ``a is b`` because ``None`` is a singleton."
2601
2615
msgstr ""
2616
+ "3) オブジェクトがシングルトンなら、それはそのオブジェクトのインスタンスは1つ"
2617
+ "だけ存在できることを意味します。 ``a = None`` と ``b = None`` 代入の後、 "
2618
+ "``a is b`` が保証されます。``None`` がシングルトンのためです。"
2602
2619
2603
2620
#: ../../faq/programming.rst:1842
2604
2621
msgid ""
@@ -2607,16 +2624,22 @@ msgid ""
2607
2624
"check constants such as :class:`int` and :class:`str` which aren't "
2608
2625
"guaranteed to be singletons::"
2609
2626
msgstr ""
2627
+ "多くの他の状況では、同一性テストは賢明でなく、透過性テストをお勧めします。 "
2628
+ "特に、シングルトンであることが保証されていない :class:`int` や :class:`str` "
2629
+ "などの定数をチェックするために同一性テストを使わないでください。"
2610
2630
2611
2631
#: ../../faq/programming.rst:1859
2612
2632
msgid "Likewise, new instances of mutable containers are never identical::"
2613
2633
msgstr ""
2634
+ "同様に、ミュータブルなコンテナの新しいインスタンスは同一ではありません::"
2614
2635
2615
2636
#: ../../faq/programming.rst:1866
2616
2637
msgid ""
2617
2638
"In the standard library code, you will see several common patterns for "
2618
2639
"correctly using identity tests:"
2619
2640
msgstr ""
2641
+ "標準ライブラリのコードには、同一性テストを正しく使うための一般的なパターンが"
2642
+ "あります:"
2620
2643
2621
2644
#: ../../faq/programming.rst:1869
2622
2645
msgid ""
@@ -2625,6 +2648,9 @@ msgid ""
2625
2648
"confusion with other objects that may have boolean values that evaluate to "
2626
2649
"false."
2627
2650
msgstr ""
2651
+ "1) :pep:`8` で推奨されるように、同一性テストは ``None`` のチェックの良い方法"
2652
+ "です。 コードの中で平易な英語のように読めますし、 false と評価される真偽値を"
2653
+ "持ちうる他のオブジェクトとの混同を避けます。"
2628
2654
2629
2655
#: ../../faq/programming.rst:1873
2630
2656
msgid ""
@@ -2633,13 +2659,20 @@ msgid ""
2633
2659
"guaranteed to be distinct from other objects. For example, here is how to "
2634
2660
"implement a method that behaves like :meth:`dict.pop`::"
2635
2661
msgstr ""
2662
+ "2) ``None`` が有効な入力値である場合、省略された引数を検出にはコツがいりま"
2663
+ "す。 そのような状況では、他のオブジェクトと区別されることが保証されたシング"
2664
+ "ルトンの番兵オブジェクトを作れます。 例えば、これは :meth:`dict.pop` のよう"
2665
+ "に振る舞うメソッドを実装する方法です:"
2636
2666
2637
2667
#: ../../faq/programming.rst:1889
2638
2668
msgid ""
2639
2669
"3) Container implementations sometimes need to augment equality tests with "
2640
2670
"identity tests. This prevents the code from being confused by objects such "
2641
2671
"as ``float('NaN')`` that are not equal to themselves."
2642
2672
msgstr ""
2673
+ "3) コンテナの実装では、等価性テストを同一性テストで補強しないといけない場合が"
2674
+ "あります。 これは、 ``float('NaN')`` のような自分自身と等価でないオブジェク"
2675
+ "トによってコードが混乱するのを防ぐためです。"
2643
2676
2644
2677
#: ../../faq/programming.rst:1893
2645
2678
msgid ""
0 commit comments