Save this video free

Python (Fall 2026) Module 14-4: Initializing a Class

Bill Moseley, Ph.D. - Computer Science Educator · 12:53 · Watch on YouTube

Part of Bakersfield College COMP B10. See all 36 lectures and search them

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

Bill Moseley explains how Python's `__init__` method initializes new class instances, accepts constructor arguments, and stores data as instance properties using `self`. A car example shows how Toyota and Ford objects keep independent makes and mileages, illustrating why instance-specific data is useful in larger programs such as employee databases.

Key takeaways

Chapters

0:00 Python's `__init__` Method Runs When a Car Object Is Created
4:44 Use `self` to Store Car Makes and Other Instance Properties
8:55 Separate Toyota and Ford Instances Keep Independent Data

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:00 So, when we, when we create an instance of a class,  when we create an object based on a class, one of the things that we say that it, the class  does, is called initialization. All initialization means is that it's setting it up and getting it  ready to go. Okay, that's the simplest definition of initialization. It's sort of like if I was  giving an old-school lecture, I would wipe down the whiteboard before I started lecturing. It's  like starting over with a clean slate, kind of getting it set up and ready to go. So, one thing  that we can do is we can define what's called an initialization method. And an initialization  method looks like this. It starts out with the

0:56 define. And it starts out with two underscores,  i n i t, and two underscores. That's a special, specific name that says, "When you create  an instance of this object, you will do this automatically." Now, if the initialization  method, obviously it's going to require self, because every method requires self. Never forget  that. But, if I put additional parameters here, then I have to give those parameters when I create  an instance of that object. So, in this case, I have intCarWheels and strCarMake. And all it's  doing is, it says, "When I create the object, I'm going to give it this, and I'm going to give  it this. I'm going to give it the make of the car

1:50 and the, how many wheels it has." So, all it's  going to do is it's going to take those things, and it's going to make properties.  self.intWheels belongs to that car, self.strCarMake belongs to that. So, it's going  to take whatever I put in here and it's going to put it in those. So, if I create a car called  myCar, and, and I set it to clCar four and Ford,

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

In this course

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Bill Moseley, Ph.D. - Computer Science Educator.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.