Y
Hacker News
new
|
ask
|
show
|
jobs
by
kstrauser
1022 days ago
You should absolutely be using `is` where appropriate. `x is None` is almost always preferable to `x == None`. If you're checking for object identity, use `is`. If equality, use `==`. They're different use cases.
1 comments
maweki
1022 days ago
Especially since == can be overwritten, while 'is' can not.
link
kstrauser
1022 days ago
That's right. Any class can define its own __eq__ method.
link