@@ -2474,13 +2474,15 @@ msgstr ""
2474
2474
2475
2475
#: ../../faq/programming.rst:1745
2476
2476
msgid "When can I rely on identity tests with the *is* operator?"
2477
- msgstr ""
2477
+ msgstr "いつ *is* 演算子での同一性テストが頼れますか? "
2478
2478
2479
2479
#: ../../faq/programming.rst:1747
2480
2480
msgid ""
2481
2481
"The ``is`` operator tests for object identity. The test ``a is b`` is "
2482
2482
"equivalent to ``id(a) == id(b)``."
2483
2483
msgstr ""
2484
+ "``is`` 演算子はオブジェクトの同一性をテストします。 テスト ``a is b`` は "
2485
+ "``id(a) == id(b)`` と同等です。"
2484
2486
2485
2487
#: ../../faq/programming.rst:1750
2486
2488
msgid ""
@@ -2489,33 +2491,48 @@ msgid ""
2489
2491
"usually faster than equality tests. And unlike equality tests, identity "
2490
2492
"tests are guaranteed to return a boolean ``True`` or ``False``."
2491
2493
msgstr ""
2494
+ "同一性テストの最も重要な特性は、オブジェクトは常にそれ自身と同一であり、 ``a "
2495
+ "is a`` は常に ``True`` を返すということです。 同一性テストは通常、等価性テス"
2496
+ "トよりも高速です。 また、等価性テストとは異なり、同一性テストは真偽値 "
2497
+ "``True`` または``False`` を返すことが保証されています。"
2492
2498
2493
2499
#: ../../faq/programming.rst:1755
2494
2500
msgid ""
2495
2501
"However, identity tests can *only* be substituted for equality tests when "
2496
2502
"object identity is assured. Generally, there are three circumstances where "
2497
2503
"identity is guaranteed:"
2498
2504
msgstr ""
2505
+ "ただし、同一性テストを等価性テストの代用とできるのは、オブジェクトの同一性が"
2506
+ "保証されている場合 *のみ* です。 一般的に、同一性が保証される状況は3つありま"
2507
+ "す:"
2499
2508
2500
2509
#: ../../faq/programming.rst:1759
2501
2510
msgid ""
2502
2511
"1) Assignments create new names but do not change object identity. After "
2503
2512
"the assignment ``new = old``, it is guaranteed that ``new is old``."
2504
2513
msgstr ""
2514
+ "1) 代入は新しい名前を作りますが、オブジェクトIDは変えません。 ``new = old`` "
2515
+ "代入の後、 ``new is old`` が保証されます。"
2505
2516
2506
2517
#: ../../faq/programming.rst:1762
2507
2518
msgid ""
2508
2519
"2) Putting an object in a container that stores object references does not "
2509
2520
"change object identity. After the list assignment ``s[0] = x``, it is "
2510
2521
"guaranteed that ``s[0] is x``."
2511
2522
msgstr ""
2523
+ "2) オブジェクト参照を格納するコンテナにオブジェクトを入れても、オブジェクトID"
2524
+ "は変わりません。 ``s[0] = x`` リスト代入の後、 ``s[0] is x`` が保証されま"
2525
+ "す。"
2512
2526
2513
2527
#: ../../faq/programming.rst:1766
2514
2528
msgid ""
2515
2529
"3) If an object is a singleton, it means that only one instance of that "
2516
2530
"object can exist. After the assignments ``a = None`` and ``b = None``, it "
2517
2531
"is guaranteed that ``a is b`` because ``None`` is a singleton."
2518
2532
msgstr ""
2533
+ "3) オブジェクトがシングルトンなら、それはそのオブジェクトのインスタンスは1つ"
2534
+ "だけ存在できることを意味します。 ``a = None`` と ``b = None`` 代入の後、 "
2535
+ "``a is b`` が保証されます。``None`` がシングルトンのためです。"
2519
2536
2520
2537
#: ../../faq/programming.rst:1770
2521
2538
msgid ""
@@ -2524,16 +2541,22 @@ msgid ""
2524
2541
"check constants such as :class:`int` and :class:`str` which aren't "
2525
2542
"guaranteed to be singletons::"
2526
2543
msgstr ""
2544
+ "多くの他の状況では、同一性テストは賢明でなく、透過性テストをお勧めします。 "
2545
+ "特に、シングルトンであることが保証されていない :class:`int` や :class:`str` "
2546
+ "などの定数をチェックするために同一性テストを使わないでください。"
2527
2547
2528
2548
#: ../../faq/programming.rst:1787
2529
2549
msgid "Likewise, new instances of mutable containers are never identical::"
2530
2550
msgstr ""
2551
+ "同様に、ミュータブルなコンテナの新しいインスタンスは同一ではありません::"
2531
2552
2532
2553
#: ../../faq/programming.rst:1794
2533
2554
msgid ""
2534
2555
"In the standard library code, you will see several common patterns for "
2535
2556
"correctly using identity tests:"
2536
2557
msgstr ""
2558
+ "標準ライブラリのコードには、同一性テストを正しく使うための一般的なパターンが"
2559
+ "あります:"
2537
2560
2538
2561
#: ../../faq/programming.rst:1797
2539
2562
msgid ""
@@ -2542,6 +2565,9 @@ msgid ""
2542
2565
"confusion with other objects that may have boolean values that evaluate to "
2543
2566
"false."
2544
2567
msgstr ""
2568
+ "1) :pep:`8` で推奨されるように、同一性テストは ``None`` のチェックの良い方法"
2569
+ "です。 コードの中で平易な英語のように読めますし、 false と評価される真偽値を"
2570
+ "持ちうる他のオブジェクトとの混同を避けます。"
2545
2571
2546
2572
#: ../../faq/programming.rst:1801
2547
2573
msgid ""
@@ -2557,6 +2583,9 @@ msgid ""
2557
2583
"identity tests. This prevents the code from being confused by objects such "
2558
2584
"as ``float('NaN')`` that are not equal to themselves."
2559
2585
msgstr ""
2586
+ "3) コンテナの実装では、等価性テストを同一性テストで補強しないといけない場合が"
2587
+ "あります。 これは、 ``float('NaN')`` のような自分自身と等価でないオブジェク"
2588
+ "トによってコードが混乱するのを防ぐためです。"
2560
2589
2561
2590
#: ../../faq/programming.rst:1821
2562
2591
msgid ""
0 commit comments