* Cantinho Satkeys

Refresh History
  • FELISCUNHA: ghyt74  pessoal  49E09B4F
    10 de Abril de 2026, 10:44
  • JPratas: try65hytr Pessoal  4tj97u<z 2dgh8i k7y8j0 yu7gh8
    10 de Abril de 2026, 06:02
  • FELISCUNHA: dgtgtr  pessoal   49E09B4F
    06 de Abril de 2026, 12:16
  • j.s.: 4tj97u<z 4tj97u<z
    04 de Abril de 2026, 23:44
  • j.s.: um santo domingo de Páscia  43e5r6 43e5r6
    04 de Abril de 2026, 23:44
  • j.s.: try65hytr a todos  49E09B4F
    04 de Abril de 2026, 23:43
  • cereal killa: feliz pascoa para todos vos e familias  101041
    04 de Abril de 2026, 16:14
  • FELISCUNHA: Votos de uma santa Páscoa para todo o auditório  4tj97u<z
    04 de Abril de 2026, 12:12
  • sacana10: Uma Feliz Pascoa
    03 de Abril de 2026, 15:05
  • JPratas: try65hytr Pessoal  4tj97u<z classic k7y8j0
    03 de Abril de 2026, 04:46
  • JPratas: try65hytr A Todos  4tj97u<z 2dgh8i k7y8j0 yu7gh8
    02 de Abril de 2026, 06:03
  • FELISCUNHA: ghyt74  pessoal   4tj97u<z
    31 de Março de 2026, 11:54
  • cereal killa: dgtgtr pessoal  r4v8p 535reqef34
    29 de Março de 2026, 17:34
  • FELISCUNHA: ghyt74 e bom fim de semana  4tj97u<z
    28 de Março de 2026, 12:00
  • j.s.: tenham um excelente domingo  4tj97u<z 4tj97u<z
    27 de Março de 2026, 21:10
  • j.s.: try65hytr a todos  49E09B4F
    27 de Março de 2026, 21:09
  • JPratas: try65hytr Pessoal  4tj97u<z 2dgh8i k7y8j0 yu7gh8
    27 de Março de 2026, 05:50
  • j.s.: try65hytr a todos  49E09B4F
    24 de Março de 2026, 18:55
  • FELISCUNHA: Votos de um santo domingo para todo o auditório  49E09B4F
    22 de Março de 2026, 11:36
  • j.s.: tenham um ex celente fim de semana  4tj97u<z 4tj97u<z
    20 de Março de 2026, 18:34

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

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

Online mitsumi

  • Sub-Administrador
  • ****
  • Mensagens: 130978
  • 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