[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So, it's Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Monty Python Flying Circus Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,okay actually it is not but just so you know Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,this is where the python language got its name Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,it is from the comedy\Nbut today's talk will be about OOP or object-orientated programming in python Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,And I am Junxi, I am a second-year student from Singapore University of Technology and Design Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,currently in the Computer Science / info systems major Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,And I am also currently an intern in Tinkerbox Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,In fact, it is my fellow intern and TechLadies' Kate who invited to speak here today Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so I am glad to here Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so now i understand that most of the audience here are beginner level Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Just to get a gauge, how many of you guys have done OOP in python before? Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Okay, I will say that for those who have not done anything Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I hope that by the end of this talk Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,we will get to understand more about Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,what OOP is about Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,'Kay, I would say OOP is like an intermediate level topic Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,but it is a very key topic for you to understand Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,for you to move on to do more advanced stuff Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so this is why I chose the topic for today Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,but also it is a very broad topic Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so i don't know how much I can cover in 20 minutes Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So forgive me if I speak too fast Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Or skip over certain things Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,okay Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,just a brief idea of what we will be talking about Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,We will only be covering, like, nuts and bolts Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,of OOP in python Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So language-specified construct syntax Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,That sort of thing Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Because I believe for beginners Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,this will be what you will be more interested in Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,but at the same time, i hope i will be able to talk a little bit about Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,what you called Object-oriented design Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,principles of writing good codes Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,with design principles, basically Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Before I actually go into the actual materials Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I have a confession to make Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,The sad truth is, okay maybe not that sad Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,but the truth is that I probably enjoy drawing silly things Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,more than I like programming so Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,as a result, you will see a lot of Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,silly drawings Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Probably more silly drawings than code Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,in this talk Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,but it is my hope that you know Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,it will sort of give you a visual aid Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,to understanding the concepts Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,that I will be talking about Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Okay so Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,let's dive right in Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Nuts and bolts Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so these are the topics I will be covering Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Objects Classes & Instances Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Attributes and Methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Inheritance and Scope Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,And those words have completely Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,flown over your head Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Do not fear Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,by the end of this talk Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you should, hopefully, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,have a rough idea of what it means Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,let's jump straight into the first... Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,oh wait, sorry. before that Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,i just want to make it clear that Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,in common use right now Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,there are two main python versions Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so python 2 and python 3 Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,there are some differences in these 2 versions Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so as beginners Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,it can be easy to trip up Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,over these differences Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so just to be clear that Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,when you read up resources online Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,for example, you should know Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,what the version Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,those resources are talking about Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,which python version they are talking about Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so for clarification Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,just be clear Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I am using python 3 for all my examples here Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,alright Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so objects Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,think of objects as a way of Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,logically encapsulating your code Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so objects has what we called attributes Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,and methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so let's look at this doggeh over here Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,i like to think of attributes as Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,kinda like Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,adjectives? Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,or properties Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So for example you say Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,the dog is white Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,or can have a weight of 7 kg Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so these are like the attributes of the dog Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,on the other hand Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,they are kinda more like verbs Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,a dog can wag tail and bark Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so these are the things Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,the dog can do Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,these are like Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,methods of my dog object Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,this is a slightly lame description Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,but i hope can bring across Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,into the field of what Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I mean by attributes and method Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,and in fact, you know Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,in python Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you have your variables and your functions Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,right? Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so your attributes and methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,are just your good ol' friends Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,your variables and functions Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,the only thing is that Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,attributes are kind of like variables Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,that are associated with a certain object Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,and methods are functions Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,that are associated with a certain object Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,in the end, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,objects basically is a way of calculating data Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,and a form of attributes Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,with functions of procedures Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,in the form of methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Okay Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so let's look at this dog transcribe into Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,real python code Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,for those who have not done any OOP in python before Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,this syntax might look intimidating but Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,hopefully by the end of it Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you will be able to understand Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,what's going on Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,The kind of object-oriented programming Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,in python Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,that we are dealing with Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,is called class-based object oriented Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,programming Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,This is the kind of OOP Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you will find Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,in languages like Ruby, Java, C# and etc. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Only the most popular kind of OOP Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Just so you know, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,there are other kinds out there Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Class-based OOP Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you see here that Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I am defining this class "dog" Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you should know by now Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,that in python, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,indentation is intactly(?) significant Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so all these indented code Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,this is inside the class body. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,This is my class definition. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Now I am talking about classes Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Now I have to talk about Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,like explain about Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,classes and instances Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Because we are talking about class-based OOP Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so what are classes and instances? Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So, think of a class as a kind of category Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,where an instance is Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,particular living example Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,of a kind of thing Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,To drive the point across, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,let me talk about babies Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Yes! Babies Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,When you think of Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,a baby right.. Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,a human baby Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you kind of have this conception Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,tectonic idea of what babies Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,should look like Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,sweet, tender, angel Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,angelic things Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,That is sort of like class Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,this general category Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,this general idea Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,whereas if you actually Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,see this real living kicking screaming Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,pooping baby Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you are like Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,"What's this ugly yoda-like thing?" Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,That is kind of like instance Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,that's the real concrete Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,instance of a baby Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So I hope that kinda brings across the idea Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,of what's the differences between Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,the class and instance Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Let's go back to the code Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,and in my class Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so in this class definition right Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,when I define my class Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you can think of it as Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,defining a custom data type Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so you know in python Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,we have our built-in types Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,we have integers Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,we have strings Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,we have lists Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,we have dictionaries Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,When you define your class Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,it is as if you are building Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,your own data type Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,And this one data type Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,has its own attributes and Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,its own methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I will go through the stuff here later Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,but let me go down to the code here Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so what you see down here Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,in this line, line 13 Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,this is where I instantiate Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I create an instance for my class Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So I am assigning Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I am creating Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,an instance called "Doggeh" Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,And this the way I construct Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,my instance Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,by calling the, what we called Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,the class constructor Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So this is the class name Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,the parenthesis Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I pass in certain arguements Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,to initialise my instance Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so now I have this Doggeh Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,which is an instance of a dog class Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Okay Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so now that we sort of know Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,what classes and instances are Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,let me go back Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I will start going through the code here Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So to understand the code in here Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,we have to talk about Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,attributes and methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,When we talk about attributes and methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,There are two kinds Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,They can be instance attributes or instance methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,or they can be class attributes and Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,class methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,But for now Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I will talking about instance attributes Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,and instance methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Because that is what we usually deal with Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Inside this class body Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I define several methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,for my dog class Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so these are how you define functions Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I mean, methods are just functions Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,but they are inside a class Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,This is how I define my methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,And Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,you notice that Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,this first method looks kind of special Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,with the double underscore in front Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,So double underscore init double underscore Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so i will be talking more about this later Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,but let's look at these two Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,func.. methods first Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,Now you will notice something interesting Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,about this method Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I mean, in the end, Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,these methods are just stuff that Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,they print something to the console Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,right Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,It is going to print "Wag Wag" or Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,"Woof Woof" Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,but there is something interesting about this Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,in the method signature Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,I am actually taking this parameter 'self' Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,and Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,this 'self' is actually an indication Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,to you that Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,these methods are instance methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,We can invoke these instance methods Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,by using this Dog syntax over here Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,so I invoke "wag tail" by Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,calling it Doggeh.wag_tail() Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,And just to emphasize that you have Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,to put the parenthesis there Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,to invoke the method Dialogue: 0,9:59:59.99,9:59:59.99,Default,,0000,0000,0000,,