Python Constructor. A constructor is a special type of method (function) which is used to initialize the instance members of the class . In C++ or Java, the constructor has the same name as its class, but it treats constructor differently in Python. It is used to create an object. Constructors can be of two types.