r/backtickbot • u/backtickbot • Jun 13 '21
https://np.reddit.com/r/learnpython/comments/nxzxgk/what_is_the_difference_between_is_and/h1kvfrg/
Don't. Right now you're using numbers, but later you will likely be using objects and sometimes it's good to know whether two objects are actually the same object in memory or not. I can't think of an example right now because it's been a while since I've programmed in python, but in C#, I can do:
if (someReference is object) { /\* blah blah blah \*/ }
else { /\* throw some kind of error because that object should never not be an object and something has gone horribly wrong! \*/ } Bottom line, it exists for a VERY good reason.
1
Upvotes