@@ -2683,6 +2683,8 @@ msgid ""
2683
2683
"The ``is`` operator tests for object identity. The test ``a is b`` is "
2684
2684
"equivalent to ``id(a) == id(b)``."
2685
2685
msgstr ""
2686
+ "O operador ``is`` testa a identidade do objeto. O teste ``a is b`` equivale "
2687
+ "a ``id(a) == id(b)`` ."
2686
2688
2687
2689
#: ../../faq/programming.rst:1834
2688
2690
msgid ""
@@ -2691,33 +2693,49 @@ msgid ""
2691
2693
"usually faster than equality tests. And unlike equality tests, identity "
2692
2694
"tests are guaranteed to return a boolean ``True`` or ``False``."
2693
2695
msgstr ""
2696
+ "A propriedade mais importante de um teste de identidade é que um objeto é "
2697
+ "sempre idêntico a si mesmo, ``a is a`` sempre retorna ``True``. Testes de "
2698
+ "identidade são geralmente mais rápidos do que os testes de igualdade. E, ao "
2699
+ "contrário dos testes de igualdade, teste de identidade garante que retorno "
2700
+ "seja um booleano ``True`` ou ``False``."
2694
2701
2695
2702
#: ../../faq/programming.rst:1839
2696
2703
msgid ""
2697
2704
"However, identity tests can *only* be substituted for equality tests when "
2698
2705
"object identity is assured. Generally, there are three circumstances where "
2699
2706
"identity is guaranteed:"
2700
2707
msgstr ""
2708
+ "Entretanto, o teste de identidade *somente* pode ser substituído por testes "
2709
+ "de igualdade quando a identidade do objeto é garantida. Em geral, há três "
2710
+ "circunstâncias em que a identidade é garantida:"
2701
2711
2702
2712
#: ../../faq/programming.rst:1843
2703
2713
msgid ""
2704
2714
"1) Assignments create new names but do not change object identity. After "
2705
2715
"the assignment ``new = old``, it is guaranteed that ``new is old``."
2706
2716
msgstr ""
2717
+ "1) Atribuições criam novos nomes, mas não alteram a identidade do objeto. "
2718
+ "Após a atribuição ``new = old`` , é garantido que ``new is old``."
2707
2719
2708
2720
#: ../../faq/programming.rst:1846
2709
2721
msgid ""
2710
2722
"2) Putting an object in a container that stores object references does not "
2711
2723
"change object identity. After the list assignment ``s[0] = x``, it is "
2712
2724
"guaranteed that ``s[0] is x``."
2713
2725
msgstr ""
2726
+ "2) Colocar um objeto em um contêiner que armazena referências de objetos não "
2727
+ "altera a identidade do objeto. Após a lista atribuição ``s[0] = x`` , é "
2728
+ "garantido que ``s[0] is x``."
2714
2729
2715
2730
#: ../../faq/programming.rst:1850
2716
2731
msgid ""
2717
2732
"3) If an object is a singleton, it means that only one instance of that "
2718
2733
"object can exist. After the assignments ``a = None`` and ``b = None``, it "
2719
2734
"is guaranteed that ``a is b`` because ``None`` is a singleton."
2720
2735
msgstr ""
2736
+ "3) Se um objeto for um Singleton, isso significa que só pode existir um "
2737
+ "instância desse objeto. Depois de atribuição ``a = None`` e ``b = None``, é "
2738
+ "garantido que ``a is b`` porque ``None`` é um Singleton."
2721
2739
2722
2740
#: ../../faq/programming.rst:1854
2723
2741
msgid ""
@@ -2726,6 +2744,10 @@ msgid ""
2726
2744
"check constants such as :class:`int` and :class:`str` which aren't "
2727
2745
"guaranteed to be singletons::"
2728
2746
msgstr ""
2747
+ "Na maioria das outras circunstâncias, o teste de identidade é "
2748
+ "desaconselhável e os testes de igualdade são preferíveis. Em particular, "
2749
+ "teste de identidade não deve ser usado para verificar constantes, como :"
2750
+ "class:`int` e :class:`str`, que não têm garantia de serem Singletons::"
2729
2751
2730
2752
#: ../../faq/programming.rst:1871
2731
2753
msgid "Likewise, new instances of mutable containers are never identical::"
@@ -2738,6 +2760,8 @@ msgid ""
2738
2760
"In the standard library code, you will see several common patterns for "
2739
2761
"correctly using identity tests:"
2740
2762
msgstr ""
2763
+ "No código da biblioteca padrão, você encontrará vários padrões comuns para "
2764
+ "usar corretamente o teste de identidade:"
2741
2765
2742
2766
#: ../../faq/programming.rst:1881
2743
2767
msgid ""
@@ -2746,6 +2770,10 @@ msgid ""
2746
2770
"confusion with other objects that may have boolean values that evaluate to "
2747
2771
"false."
2748
2772
msgstr ""
2773
+ "1) Conforme recomendado por :pep:`8`, um teste de identidade é a maneira "
2774
+ "preferida de verificar ``None``. Isso é lido como se fosse inglês simples "
2775
+ "no código e evita confusão com outros objetos que podem ter valor booleano "
2776
+ "avaliado para falso."
2749
2777
2750
2778
#: ../../faq/programming.rst:1885
2751
2779
msgid ""
@@ -2754,19 +2782,29 @@ msgid ""
2754
2782
"guaranteed to be distinct from other objects. For example, here is how to "
2755
2783
"implement a method that behaves like :meth:`dict.pop`::"
2756
2784
msgstr ""
2785
+ "2) A detecção de argumento opcional pode ser complicada quando ``None`` é "
2786
+ "uma valor de entrada válido. Nessas situações, você pode criar um objeto "
2787
+ "Singleton sinalizador com garantia de ser distinto de outros objetos. Por "
2788
+ "exemplo, veja como implementar um método que se comporta como :meth:`dict."
2789
+ "pop`::"
2757
2790
2758
2791
#: ../../faq/programming.rst:1901
2759
2792
msgid ""
2760
2793
"3) Container implementations sometimes need to augment equality tests with "
2761
2794
"identity tests. This prevents the code from being confused by objects such "
2762
2795
"as ``float('NaN')`` that are not equal to themselves."
2763
2796
msgstr ""
2797
+ "3) Implementações de contêiner às vezes precisam combinar testes de "
2798
+ "igualdade com testes de identidade. Isso evita que o código seja confundido "
2799
+ "por objetos como ``float('NaN')`` que não são iguais a si mesmos."
2764
2800
2765
2801
#: ../../faq/programming.rst:1905
2766
2802
msgid ""
2767
2803
"For example, here is the implementation of :meth:`!collections.abc.Sequence."
2768
2804
"__contains__`::"
2769
2805
msgstr ""
2806
+ "Por exemplo, aqui está a implementação de :meth:`!collections.abc.Sequence."
2807
+ "__contains__`::"
2770
2808
2771
2809
#: ../../faq/programming.rst:1916
2772
2810
msgid ""
0 commit comments