__init__() not called automatically
Tim Leslie
tim.leslie at gmail.com
Thu May 26 00:46:49 EDT 2005
On 25 May 2005 21:31:57 -0700, Sriek <scharan20 at gmail.com> wrote:
> hi,
> i come from a c++ background. i ws happy to find myself on quite
> familiar grounds with Python. But, what surprised me was the fact that
> the __init__(), which is said to be the equivlent of the constructor in
> c++, is not automatically called. I'm sure there must be ample reason
> for this. I would like to know why this is so? This is my view is more
> burden on the programmer.
>>> class C:
... def __init__(self): print "Hello"
...
>>> c = C()
Hello
This looks like __init__ being called automatically to me. Are you
doing something different?
> Similarly, why do we have to explicitly use the 'self' keyword
> everytime?
http://www.python.org/doc/faq/general.html#why-must-self-be-used-explicitly-in-method-definitions-and-calls
>
> Every kind of help would be welcome.
No worries,
Tim
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list