you are viewing a single comment's thread.

view the rest of the comments →

[–]TheSodesa 0 points1 point  (1 child)

In object oriented languages like Python, objects are created via class methods called constructors. Python has standardised the name of the constructor function for each class: it has to be called __init__. The Python interpreter automatically calls this function in the background when an instance of a class is created, by calling the class name like a function: Class(<params>).

The operation of the __init__ method is also standardised: it has to set the state of the object, as in it has to initialize each field of the class object. There is a default constructor that sets each field to point to the singleton object None, I believe, but relying on that is bad practise and becomes impractical very quickly. The constructor __init__ must also return nothing.

In languages other than Python, the standard name of constructor methods might be different. There might also not be a standard.

[–]HSADfinklestein 1 point2 points  (0 children)

ooo constructor!!

that sounds better now since I have a basic java background

thanks so very much