Showing posts with the label constructors

Python Constructors Init and Del Easy Way to Understand

Python class has two constructors. One is the init, and the other one is del. Why you need these two and their real purpose explained. The initialization method is called __init__ while the finalization or destructor method is called __del__. Python methods with a double underscore character are for internal (not intended for direct access by the outside world) use. There are no true private methods in Python classes, but convention says that a method that begins with a single underscore is considered private, and a double underscore indicates it is internal (only to be used by the system.) Python Constructors Init and Del Easy Way to Understand Init Constructor object.__init__(self[, ...]) Called after the instance has been created (by __new__() ), but before it is returned to the caller. The arguments are those passed to the class constructor expression.  If a base class has an __init__() method, the derived class’s __init__() method, if any, must explicitly call it to ensure prope