python - Is this a constructor or a method -
is __init__ in python constructor or method?
somewhere says constructor , somewhere says method, quite confusing.
it correct call method. incorrect, or @ best inaccurate, call constructor.
specifically, magic method. called special methods, "dunders", , few other names.
this particular method used define initialisation behavior of object. not similar constructor, , not first method called on new instance.
we use __init__ set state of already-created instance. automatically called when use syntax a() create instance of class a, why might loosely refer "constructor". responsibility of __init__ not related instance construction, __new__ magic method more similar constructor in respect.
Comments
Post a Comment