__init()__ Constraint or Convention?

Just curious, does the constructor __init()__ have to be labelled as ‘init’ in order to function properly? Or could it be possible to name this constructor something else while still defining the appropriate .self functionality and have your code function as normal? I suppose I am curious if the name is simply convention or if python could not understand it otherwise.
Thanks!

Hi !

It needs to be called this. If you want more under-the-hood explanation check out the docs: https://docs.python.org/3/reference/datamodel.html#object.init.
There might be a contrived way to replicate functionality but it would be pretty advanced.

2 Likes

Cool! Thanks for this guidence.