__eq__ & is vs == | Python Quick Tips

preview_player
Показать описание
This python quick tips video discusses the difference between == and is and how we can implement == functionality on our objects with the dunder method __eq__ . This is not so much a quick tip but a very important concept in python that I wanted to introduce.

Let me know what else you want to see from this series!

◾◾◾◾◾
💻 Enroll in The Fundamentals of Programming w/ Python

◾◾◾◾◾◾

⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡


Tags:
- Tech With Tim
- Python Tutorials
- is vs ==
- == vs is
- __eq__ python

#Python #PythonQuickTips
Рекомендации по теме
Комментарии
Автор

It's worth noting that if __eq__ is not implemented, then it behaves as "is":

In [1]: class Dog:
...: def __init__(self, name):
...: self.name = name
...:
In [2]: tim = Dog("tim")
In [3]: joe = tim
In [4]: joe == tim
Out[4]: True

muizzy
Автор

These terms require a good explanation since they seem complicated...

But they are important to understand...

👍👍👍👍

SkyFly
Автор

Awesome.Big thanks for uploading videos on daily basis it is helpful.

nakulsingh
Автор

Its pretty clear description of this methods thanks.
But I don't understand why there is only 7k views, is that because topic is harder than another videos on this channel?

ungeheurenungeziefer
Автор

THANK YOU SO MUCH! I needed this dearly lmao

gamaltk
Автор

Very nice videos. Waiting for upcoming videos on python. Thank you 😊❤️.

priteshpawar
Автор

Thanks. Very clear indeed. Waiting for more interesting stuff like this

alex
Автор

Okay so....dunder methods are like operator overloading in cpp??

siliconmessiah
Автор

Much love to you from Azerbaijan. Thanks for the tips!

sadiqabbaszade
Автор

Great explanation! Thank you for making these awesome vids, they help me out a lot: -)

fredericoamigo
Автор

Really helpful, can you make a video over some usefull dunder methods available in python with use cases

pushpajitbiswas
Автор

bro explained it better in six minutes than my profs that took 30 minutes

serineprotease
Автор

Your eq implementation can just be written like:
return isinstance(other, Dog) and other.name == self.name

tomershechner
Автор

hello tim awesome videos. i request you to start complete project based series on django/python. thank you.

rayganmudberry
Автор

Why u didn’t use just return self.other == self.name

sergeykapshuchenko
Автор

class Dog:
def __init__(self, name):
self.name = name

obj1 = Dog("Tim")
obj2 = Dog("Tim")
print(obj1.name is obj2.name)

can anyone tell me, why does this program print "True"?

n_shuvo
Автор

What is this code style? Looks damn nice

erezavior
Автор

Now I want to know when to use == or is? At least I learn also that they are not the same thing.

romariocarvalhoneto
Автор

I thought this is a Burmese Python care video. What is this???

HugeMeatMan