 What's up, guys? Root from nullshell.com here today, and we are looking at even more Python. We're continuing our little object-oriented programming series, our OOP, little extravaganza that we've got going on. And we've been looking at classes, or the structure behind, let's see, our objects and our instances. Now, we had a problem in the last tutorial, though, that we were working with the variable that we had not been set, that may or may not have been set. It all depends on if we called the function prior. Now, this is kind of a bad thing. So in classes, though, we have two special functions. We have constructors and deconstructors. Constructors are what's going to run, or what's going to happen when the object is first created. Immediately when the object is created, that function will run. So that's where you can set, you can initialize variables. You can declare things that you're going to be working with, and maybe you could even display some out, but on the screen if you really wanted to, it's all up to you. And the destructor is kind of the opposite. It's what's going to happen when the object is destroyed, or when it's removed from the computer's memory. And this usually tends to happen when the program ends, if it's not done beforehand. So let's take a look at this in idle, though, because there's a lot to work with, and there's a lot that we can talk about with this. So I'm going to create a, let's see, a new script here. File.python, overwrite that, get a shebang line coming along. Environment Python. Okay, cool. So let's get our class set up. Let's create another person, just like we did last time. Remember, we don't need any, we don't need to run the season to class bit. So let's get, now that we're inside our code block, let's talk about the syntax. The syntax for the constructor and the deconstructor are a little special, and they're a little weird at that same time. What we have are two keywords, init and dl. I'm thinking this is initialize, and the other one is delete, because I feel like that makes the most sense to me, but these are wrapped in two underscores. There's two underscores before and after this. So if we type in def to define a function, we type in init with our two underscores, get a parameter set up, self is always going to have to be there because you're defining a function inside a class, as you know, and we'll get a code block going on. Okay, so now we've got our constructor. Now what we type in here is going to happen automatically when this object is created. So I'm just going to say, I am the constructor. This is really, really basic, but it'll work for now. So let's get our Andrew again, and Andrew is a new person. So when you run this, it says I am the constructor, because right when that object is created, it's going to skip right back up here and run that constructor. So what we can do is we can set variables in this constructor. We can set self.name to be equal to Andrew Robinson. We can run that, and now nothing is going to happen because we aren't displaying anything, but we've set a variable. If we go back here and we have Andrew, Andrew has a... Let me get back to what I'm doing here. Holy goodness. Andrew, if we do control space to autocomplete, we can see that Andrew has a new variable, name, and Andrew is Andrew Robinson, because it's been automatically set by the constructor. Now, this is convenient too, because we can just say, let's get started with our deconstructor. And now this is that same sort of syntax, except we're using the DEL keyword for delete. We're going to want self, because it's a function inside a class, as always, and now we can display self.name has died. So Andrew is a person, and he's going to live his life. Andrew Robinson, there we go. And let's see here. Andrew Robinson is a person. When that happens, we have DEL in it. Andrew Robinson is his name, self.name has died. So if we delete Andrew, we can run this, Andrew Robinson has died, Andrew Robinson has died. DEL is the keyword to delete a object, or any other sort of variable or that sort of thing. But if we don't do this, if we don't do this prior, until the ending, because let's see, delete Andrew, this is going to give us an error, because Andrew obviously has not been defined yet, but when we run this and we don't delete him, when the program ends, obviously he's going to be removed from memory. So if we run this, nothing happens. If we run this, Andrew Robinson has died. Andrew Robinson has died, Andrew Robinson has died, because we're creating him, and then he gets his name set, and then he dies, because the program has ended. So this is a little sad, don't you think? We're killing people here. But no, we can set this to whatever we'd like, we can set it to maybe Brian Longhorn, because that's just a funny name. Andrew Robinson, if we run it again, Brian Longhorn has died. Huh, okay. So we can set things inside the constructor, we can display things in the constructor, and when the object is removed from memory, or when the program ends, we can do things as well. So we could just say print, I am the deconstructor. You might hear the word destructor. It could be either destructor or deconstructor, it all depends on, I guess really whatever you prefer to call it. There's a little bit of controversy between what you call it, so Brian Longhorn has died, I'm the deconstructor, Brian Longhorn has died. Because we run it again while it's actually using this new Andrew, rather than creating a different one. Because that's the problem with running it inside idle, it has some of the variables that it's already been left over, but yeah. Alright, I think that's all I want to cover in this video. We're going to be going more in depth with these guys, especially the constructor later on, because the constructor is just so crucial. But yeah, that's all I've got for you guys now. Thank you for watching, thank you for listening, and I will see you guys in the next tutorial. Bye.