- The
__init__method makes classes aware of each other if more than one class is defined in a single code file. - The
__init__method is included to preserve backwards compatibility from Python 3 to Python 2, but no longer needs to be used in Python 3. - The
__init__method is a constructor method that is called automatically whenever a new object is created from a class. It sets the initial state of a new object. - The
__init__method initializes any imports you may have included at the top of your file.
Correct Answer:
- The
__init__method is a constructor method that is called automatically whenever a new object is created from a class. It sets the initial state of a new object.
Example:
class test:
def __init__(self):
print('I came here without your permission lol')
pass
t1 = test()
>>> 'I came here without your permission lol'