Python Tutorial 38 --- "Self & __init__() (Constructors)(OOPS 3)"
Python Tutorial 38 --- "Self & __init__() (Constructors)(OOPS 3)" Doc --- In this tutorial, we will be discussing methods and constructors in detail. If you are familiar with any other object-oriented programming language, then the concept will be easy for you to grasp. So, let us begin with the Method. Method: A method is just like a function, with a def keyword and a single parameter in which the name of the object has to be passed. The purpose of the method is to show all the details related to the object in a single go. We choose variables that we want the method to take but do not have to pass all of them as parameters. Instead, we have to set the parameters we want to include in the method during its creation. Using methods make the process simpler and a lot faster. Self keyword: The self keyword is used in the method to refer to the instance of the current class we are using. The self keyword is passed as a parameter explicitly every time we define a m...
Comments
Post a Comment