[Tutor] def __init__(self):

Ben Finney ben+python at benfinney.id.au
Tue Apr 26 16:51:10 EDT 2016


Santanu Jena <santanu01 at gmail.com> writes:

>  I have idea regarding " __init__" method/ class.but still I have
> confusion on "def __init__(self): "

What is the confusion? Please say what you are expecting, and what is
happening instead that confuses you.

(Also, please don't top-post. Instead, post with replies interleaved
<URL:https://en.wikipedia.org/wiki/Posting_style#Interleaved_style>
and remove quoted material to which you are not responding.)

> Please share your under standing.

The ‘__init__’ method is the object initialiser. During the construction
of an object, the constructor ‘__new__’ is called (to construct the
object and return it), but before it is returned the new instance's
‘__init__’ method is called. This allows the constructed instance to
perform any of its own custom initialisation.

-- 
 \      “If I haven't seen as far as others, it is because giants were |
  `\                           standing on my shoulders.” —Hal Abelson |
_o__)                                                                  |
Ben Finney



More information about the Tutor mailing list