Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
Due to its power, simplicity, and complete object model, Python has become the scripting language of choice for many large organizations, including Google, Yahoo, and IBM. In Python 3 Essential Training, Bill Weinman demonstrates how to use Python 3 to create well-designed scripts and maintain existing projects. This course covers the basics of the language syntax and usage, as well as advanced features such as objects, generators, and exceptions. Example projects include a normalized database interface and a complete working CRUD application. Exercise files accompany the course.
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.
Find answers to the most frequently asked questions about Python 3 Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
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.