 What's going on, guys? Rudlinal here, and we are checking out some more Python code. We were back into our little object-oriented programming adventure, and now we're looking at constructors more in-depth. In the last video, we took a look at constructors and destructors and that sort of thing, but we were only passing one argument to the constructor. We were passing that self keyword, which is mandatory for all functions inside of a class. So what if we were passing more parameters and more arguments to that function, though? What if we sent in more information for the object to be able to process, and that sort of thing? So let's try it. Let's get idle started up. Drag this right over here so you guys can see it, and we'll get started with a new program, Ctrl-N. I'm going to save this as file.python for the moment. We can overwrite whatever's there. Get my shebang line going on, as always, and we can get started. Now we're going to want our class again. Remember, we don't use any parameters inside that declaration. We don't have any parentheses, and that sort of thing, and we use DEF to define a function in it for the constructor with two underscores, and we always want that self parameter no matter what we're doing. Let's get a deconstructor going on while we're there just to make sure it's working smoothly and everything like that. And let's not forget to create an object, first of all. Andrew can be our person. So if we run this, let's make sure the constructor is all set. We can just print out, hello world. F5, run the program. Oh, got an error. There's an error in our program, expected in indented block. Let's see, what do we have here? Oh, now this is an interesting thing. If you ever define a function where you are not actually doing anything in there but you want to have that set up for later, you can't have anything in that. You can't just leave that function completely blank. So what you can do is you can type in pass. Now pass is a keyword that will do absolutely nothing. It's kind of interesting that we create that, but it makes the program wait or do nothing. So if you set up an infinite loop inside the infinite loop you had it pass, it'll do nothing over and over and over again. It'll just keep waiting. So let's try it though. Let's run this program again. Now that we have our pass in there and the constructor works. We're printing out hello world. So now let's get ourselves some more variables. Let's do self.name. We can have Andrew Robinson just like we did some of the earlier videos. Self.age can be, let's say, 18. Let's get ourselves a new function. Let's define a say hello self. We can print out self.name plus, and a new string here says, actually we can do who is, we can add on the, we can concatenate on the age. We can add another string variable except we should turn this integer into a string here with that string function. We can cast that data type and we can say says hello. Now that's all set. If we run this code, nothing happens because we aren't doing anything in the constructor, but we have Andrew. Andrew has been created. So if we look at Andrew with our auto completion feature with the control backspace, I'm sorry, the control space bar, we have all these variables. We have age, we have name, and we have say hello. Now say hello is a function or a method just like we've been working with and we can run that. Andrew Robinson, who is 18, says hello. Now this is using both the variables that we've set up. This is using the age, the integer form, 18 up there. And we're also using his name, Andrew Robinson. Okay, so this works for us, but what if we wanted to set this up in the person's declaration when we're activating that object? What if we passed in some arguments to the constructor? We can set up name and age. So this way self.name can equal age. I'm sorry, self.name can equal name and self.age can equal age. Now if we run this now, it's going to yell at us because it takes those three arguments and we've only passed in self because it doesn't automatically since it's an object, but we still have name and age to worry about. We can't just call it without those parameters. So let's pass in Andrew White this time and let's say he's 26. I don't care. At five, now that he's ran, we can have Andrew say hello inside our interactive shell. Andrew White, who is 26, says hello. Okay, that works for us. We can pass in those parameters. But what if we set up some default parameters? What if we went back to our constructor's declaration and took a look at name equals and then we can supply a string for this? Name can equal Andrew. Actually, we'll name him unnamed and the age can be zero because he hasn't actually been supplied yet. So we have Andrew. We can run. We can work with Andrew. That's fine. And we'll inside the script, we'll have Andrew say hello. Keep it easy. Now when we run it, Andrew White, who is 26, says hello. And now we can have, let's say, Bob. Bob is another person, but we're not going to pass any arguments to him. He's just going to use the default parameters. So now we have Bob. He's run, but we need to have him say hello. Now Bob is going to say unnamed, who is zero, says hello. Okay, so now we've got this to work. We have our little parameters here. We've used default parameters if they don't pass anything and that sort of thing. So let's work with a little bit more. Let's check out the deconstructor. If we have, let's see, actually let's get rid of Bob first of all. We don't need him anymore. We could comment him out, but I don't plan on using him. So we can just say print self.name in our case. Actually we can do rest in peace, self-name. And then who died at the age of, we're going to want to concatenate on there that string variable of self.age. And I'm going to make this window a little bit bigger. So now, okay, cool. So now if we run this, and I'm actually, I don't want to run this in idle though. I think I should run this from the terminal because I don't want idle to get mixed up with those memory things, with those having an instance be created and then destroyed and vice versa. So I'm going to change mod file.python. Now if we run file.python, Andrew Wright, who is 26, says hello. And rest in peace, Andrew White, who died at the age of 26. So we've taken in the parameters that we passed in the constructor for Andrew. And we've, let's see, we've added them to the constructor. And we've had him say hello with his name, with his age and everything. And then we've run the deconstructor, which he dies. Rest in peace, Andrew White, who died at the age of 26. Now let's try this with Bob again. Let's put Bob back in here. Bob equals a person. And let's not pass any arguments to him. If you actually, if you hit control backslash while you're inside the parentheses, you can see the variables that you're going to be wanting to pass in. But they are optional though. They're default parameters with unnamed and age zero. So if we have Bob and we just, we don't even tell him to say hello. He's just going to die anyway. We don't care. So hey, let's check it out. Let's run file.python. And rest in peace unnamed, who died at the age of zero. Now Bob, we aren't modifying any of his things with the constructor here, but we are just using the name and the age that are set up as default parameters. So what if we took this to a different level though? What if we actually set up some functions to set the name and the age? We can define set name. We'll say self and name to be set to. Name to be set to, not name to bet to. Be set to. Get our code block going. I'm going to use my comments as usual. And we will use self.name can be equal to name to be set to. Or whatever you have named the argument inside your function declaration. Let's set this up again for the age. Self.age and then age to be set to. And change all these variables once again. And now we have Andrew. I'm not going to worry about Bob, but idle is not going to kill it. So we're not going to run it in idle. I'm going to switch back to my terminal. Clear the screen one at one more time. Andrew White, who is 26, says hello. Rest in peace, Andrew White, who died at the age of 26. Okay, so he's using the default things. But what if we set up Andrew and then we set his name to be Doug Larkin. Doug Larkin. And we can set, let's not set his age yet. But if we switch back to our terminal, idle to clear the screen and then file out Python. Andrew White, who is 26, says hello. And rest in peace, Doug Larkin, who died at the age of 26. So it's taking Andrew's name and changing it to Doug Larkin by using the function that we've already set so we can overwrite the current name variable. And we can do this again with Andrew.set age. And let's pass in, let's say, 9,854. Because people live that long or something. So, control L, run Python. And then Andrew White, who is 26, says hello. Rest in peace, Doug Larkin, who died at the age of 9,854. Repeating. So, thank you guys. Thank you for watching. I think we've covered everything in here. We've got some optional parameters. We've got some default parameters. We've set parameters for the constructor. We don't have to worry about parameters for the deconstructor because that's just silly. You would never be able to set that up. So, yeah. Thanks for listening, guys. Thank you for watching. It'd be cool if you could give me a like. Maybe leave a comment. Tell me what you think. And maybe subscribe, you know, do your thing. But I'll see you again. Thanks for watching, guys. And have a great day.