Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
== compares values using __eq__, while is checks whether two names refer to the exact same object; use is mainly for None and other singletons.
a == b asks whether two objects are equal, which classes can define through eq. a is b asks whether they are the same object in memory. Two separate lists with the same contents are equal but not identical. CPython caches small integers and some strings, so is can appear to work for them, but that is an implementation detail and should never be relied on. The idiomatic uses of is are comparisons with None, True, False or sentinel objects.