Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Everything in Python 3 is an object: variables, functions, even code; all of these things are actually objects. In Python every object has an ID, a type, and a value. The id is a unique identifier that identifies a particular instance of an object. This cannot change for the life of the object. The type identifies the class of an object, and again this cannot change for the life of the object.
The value is the contents of the object, including whatever variables, or methods, or properties the object may have. Mutable objects can change their value; immutable objects cannot. Let's take a look in an example of an object. This is idle. It's the graphical interface of the Python shell. Python comes with this in graphical environments like Windows and Mac. And if you are in a non-graphical environment, an environment with just a command line, you can just run the Python by interpreter with the command line and you'll get exactly the same interface.
So let's go ahead and create a variable. For example, let's create an object. We'll call it x, and we'll assign it the number 42. So we type x by itself. The Python shell here will give us the value of x. So that's its value. Its id is this number, and the size of the number, what the number looks like is going to be different depending on what your implementation is. Generally, it's like an address. It is a unique identifier that identifies this particular object.
And the type of x is class int. And you remember everything in Python is an object, and so objects have class. Their type is a class. And so in this case it's an integer. All variables in Python are first- class objects, and what that means is that what might look like a simple variable may actually be something more complex. It could be an object that's been defined in a library, it could be a built-in object, it can be any sort of a thing, and it will oftentimes have attributes and methods, and we'll get into the details of that later on in the course.
But for now what's important to understand is that everything in Python is an object, including variables, and as we look at variables and we look at the types of variables and how we use them, you need to realize that they are objects, and we'll oftentimes be using syntax like this v.attribute or v.method to access the attributes and the methods within those objects.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98434 Viewers
61 Video lessons · 85719 Viewers
71 Video lessons · 69638 Viewers
56 Video lessons · 101962 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.