5 ответов
+ 5
if you don't override the __eq__ method, == and is give the same result.
if you override the methode to define what is the equality (in my code example, p1 equal to p2 if p1.name=p2.name and p1.age=p2.age, in this way you will get different result
try this code 😉
https://code.sololearn.com/c7C4L9H7KYHZ/?ref=app
+ 8
hmm, ‘is’ checks if two objects are identical in every way while ‘==‘ checks if both values are the same.
Be careful, ‘=‘ is an assigment, different from ‘==‘ 😁
+ 7
"Is" is used for the comparison ( returns true or false) and "=" is used for affection ( for exemple
L1=[]
L= [1,2,3]
L1=L
Print (L1)
>>> [1,2,3]
+ 6
roula ez femma faute de frappe je l'ai corrigé dans la question ; no9sod difference bin "==" et "is" ; merci comme meme pour le reponse
+ 4
Choe thanks for answering ; yes i made a mistake ; i mean the difference between "==" and "is"