__init__

As we mentioned already, this method represents the initialization of a class instance. It is called any time you initialize a class. It is usually stored to add some properties you're passing upon initialization, and running any kind of initialization setup. During initialization, you can call any other method of the object. Here is an example:

class Animal:
def __init__(self, age, diet):
self.age = age
self.diet = diet

In this example, we created an Animal class and stored two attributes, age, and diet, upon initialization.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset