ABSTRACT

The class keyword generates a new class definition. The class definition starts with the keyword class. Class methods is different from that of the normal functions, the first argument of the class methods is the self-argument. Python automatically adds up the self-argument to the methods, the programmers need not include the self-argument at the time of calling the methods. The self-parameter describes the current instance of the class and access the class variables. The self must be the first parameter of the class-related functions. To invoke the methods or variables of the class, use the dot notation. The programmers can retrieve the objects attributes using the dot operator with object. The class methods use the cls parameter instead of the self parameter. Every class in the Python has the default constructor when the programmer does not provide the explicit constructor. The constructor is of three types: Default constructor, Parameter-less constructor and Parameterized constructor.