Checking the Identity of Objects
00:00
In this lesson, you’ll see a best practice for using not when checking for object identity.
00:08
Every object in Python has a unique identifying number which can be found using the id() function. If two names have the same id() value, then they are both referring to the same object.
00:21
In Python you use the is operator to see if two names are really representing the same object. For example, if you create a variable, obj, then assign it to None, the is operator will tell you that obj really is None.
00:39
It’s another name for None. If you want to test if two names represent different objects, you use not much in the same way you saw in the last lesson.
00:51
It’s preferred to check obj is not None than to type not obj is None.
01:04 Next you’ll look at best practices for avoiding unnecessary negative logic.
Become a Member to join the conversation.
