The special method __init__ is the constructor method of the class. A constructor is a special method that executes each time an object of a class is created. The constructor (method __init__) initializes the attributes of the object and returns None. Python classes may define several other special methods, identified by leading and trailing double-underscores (__) in the name.
Returning a value other than None from a constructor is a fatal, runtime error.
No comments:
Post a Comment