* Cantinho Satkeys

Refresh History
  • FELISCUNHA: ghyt74  pessoal  4tj97u<z
    21 de Abril de 2025, 10:38
  • cereal killa:
    19 de Abril de 2025, 21:17
  • j.s.: tenham uma Santa e Feliz Páscoa  49E09B4F 49E09B4F 49E09B4F
    19 de Abril de 2025, 18:19
  • j.s.:
    19 de Abril de 2025, 18:19
  • j.s.: dgtgtr a todos  4tj97u<z 4tj97u<z
    19 de Abril de 2025, 18:15
  • FELISCUNHA: Uma santa sexta feira para todo o auditório  4tj97u<z
    18 de Abril de 2025, 11:12
  • JPratas: try65hytr Pessoal  4tj97u<z classic k7y8j0
    18 de Abril de 2025, 03:28
  • cereal killa: try65hytr malta  classic 2dgh8i
    14 de Abril de 2025, 23:14
  • FELISCUNHA: Votos de um santo domingo para todo o auditório  101041
    13 de Abril de 2025, 11:45
  • j.s.: e um bom domingo de Ramos  43e5r6 43e5r6
    11 de Abril de 2025, 21:02
  • j.s.: tenham um excelente fim de semana  49E09B4F
    11 de Abril de 2025, 21:01
  • j.s.: try65hytr a todos  4tj97u<z
    11 de Abril de 2025, 21:00
  • JPratas: try65hytr  y5r6t Pessoal  classic k7y8j0
    11 de Abril de 2025, 04:15
  • JPratas: dgtgtr A Todos  4tj97u<z classic k7y8j0
    10 de Abril de 2025, 18:29
  • FELISCUNHA: ghyt74  pessoal   49E09B4F
    09 de Abril de 2025, 11:59
  • cereal killa: try65hytr pessoal  2dgh8i
    08 de Abril de 2025, 23:21
  • FELISCUNHA: Votos de um santo domingo para todo o auditório  43e5r6
    06 de Abril de 2025, 11:13
  • cccdh: Ola para todos!
    04 de Abril de 2025, 23:41
  • j.s.: tenham um excelente fim de semana  49E09B4F
    04 de Abril de 2025, 21:10
  • j.s.: try65hytr a todos  4tj97u<z
    04 de Abril de 2025, 21:10

Autor Tópico: Comparing Python Objects the Right Way: "is" vs "=="  (Lida 98 vezes)

0 Membros e 1 Visitante estão a ver este tópico.

Online mitsumi

  • Moderador Global
  • ***
  • Mensagens: 119389
  • Karma: +0/-0
Comparing Python Objects the Right Way: "is" vs "=="
« em: 15 de Junho de 2021, 09:04 »

MP4 | Video: h264, 1920x1080 | Audio: AAC, 44.1 KHz, 2 Ch
Genre: eLearning | Language: English | Duration: 5 Lessons (28m) | Size: 75.1 MB

There's a subtle difference between the Python identity operator (is) and the equality operator (==). Your code can run fine when you use the Python is operator to compare numbers, until it suddenly doesn't. You might have heard somewhere that the Python is operator is faster than the == operator, or you may feel that it looks more Pythonic. However, it's crucial to keep in mind that these operators don't behave quite the same.

The == operator compares the value or equality of two objects, whereas the Python is operator checks whether two variables point to the same object in memory. In the vast majority of cases, this means you should use the equality operators == and !=, except when you're comparing to None.

In this course, you'll learn:

What the difference is between object equality and identity
When to use equality and identity operators to compare objects
What these Python operators do under the hood
Why using is and is not to compare values leads to unexpected behavior
How to write a custom __eq__() class method to define equality operator behavior


Download link:
Só visivel para registados e com resposta ao tópico.

Only visible to registered and with a reply to the topic.

Links are Interchangeable - No Password - Single Extraction