* Cantinho Satkeys

Refresh History
  • FELISCUNHA: Votos de um santo domingo para todo o auditório  4tj97u<z
    07 de Dezembro de 2025, 11:23
  • j.s.: tenham um excelente domingo :smiles_natal:
    06 de Dezembro de 2025, 23:36
  • j.s.: try65hytr a todos :13arvoresnatalmagiagifs:
    06 de Dezembro de 2025, 23:36
  • FELISCUNHA: ghyt74 pessoal  :34rbzg9:
    05 de Dezembro de 2025, 11:58
  • JPratas: try65hytr Pessoal  4tj97u<z classic k7y8j0
    05 de Dezembro de 2025, 04:18
  • cereal killa: try65hytr pessoaal  :13arvoresnatalmagiagifs:  RGG45wj
    04 de Dezembro de 2025, 18:51
  • Bobo2009: Os nova
    01 de Dezembro de 2025, 21:02
  • FELISCUNHA: Votos de um santo domingo para todo o auditório   4tj97u<z
    30 de Novembro de 2025, 12:06
  • j.s.: tenham um excelente fim de semana  :smiles_natal:
    29 de Novembro de 2025, 14:19
  • j.s.: dgtgtr a todos  :13arvoresnatalmagiagifs:
    29 de Novembro de 2025, 14:18
  • FELISCUNHA: ghyt74   49E09B4F  e bom fim de semana  4tj97u<z
    29 de Novembro de 2025, 11:37
  • cereal killa: try65hytr pessoal ja cheira a prendas  erfb57j p0i8l
    28 de Novembro de 2025, 22:04
  • JPratas: try65hytr Pessoal  2dgh8i k7y8j0 classic
    28 de Novembro de 2025, 05:14
  • FELISCUNHA: ghyt74  pessoal   k8h9m
    27 de Novembro de 2025, 11:42
  • j.s.: try65hytr a todos  4tj97u<z
    24 de Novembro de 2025, 20:57
  • FELISCUNHA: Votos de um santo domingo para todo o auditório  4tj97u<z
    23 de Novembro de 2025, 11:57
  • euro: Clube de Baile
    22 de Novembro de 2025, 17:55
  • cereal killa: dgtgtr pessoal inimigo  k8h9m ta um calor do karago  RGG45wj
    21 de Novembro de 2025, 15:46
  • FELISCUNHA: ghyt74   49E09B4F  e bom fim de semana  4tj97u<z
    21 de Novembro de 2025, 11:49
  • JPratas: try65hytr Pessoal  2dgh8i  classic k7y8j0 yu7gh8
    21 de Novembro de 2025, 03:37

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

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

Online mitsumi

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