On 26 May 2005 11:54:33 -0400, Roy Smith [EMAIL PROTECTED] wrote:
And the correlary wart in Python is that the first argument to a
method is not required to be called self. The vast majority of
people use self, but every once in a great while you run into some
yahoo who feels this is the
have c++ compiler installed, but I don't even
bother validate my last paragraph assertion. Too disgusting. ;)
Sriek wrote:
Tim pointed out rightly that i missed out the most crucial part of my
question.
i should have said that __init__() is not called automatically only for
the inheritance
if i understand C++ right, in c++ you CAN explicitly call the base
constructor ( for eg. if it requires some particular arguements ), but,
the compiler automatically has to call the base class constructor ( see
the rules for constructing an object of the derived classes ).
But, yes, C++ can be
maybe like this:
we can have the default behaviour as calling the default constructor
( with default arguements where required ). Along with this, keep the
option open to call constructors explicitly.
My only contention is that there may be a greater reason for this rule
in the Python Language.
On Wed, 25 May 2005 21:31:57 -0700, Sriek wrote:
Similarly, why do we have to explicitly use the 'self' keyword everytime?
I didn't like that when starting Python. Now when I look back at C++ code,
I find it very hard to work out which variables and methods and members,
and which are not,
Sriek [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
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
On 25 May 2005 21:31:57 -0700,
Sriek [EMAIL PROTECTED] wrote:
Similarly, why do we have to explicitly use the 'self' keyword
everytime?
Why do they (the C++ programmers) prepend m_ to otherwise perfectly
good member names?
Regards,
Dan
--
Dan Sommers
http://www.tombstonezero.net/dan/
--
Sakesun Roykiattisak [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Does c++ call base class constructor automatically ??
If I'm not wrong, in c++ you also have to call base class constructor
explicitly.
In C++, if you don't call a base-class constructor (I am saying a rather
Sriek wrote:
maybe like this:
we can have the default behaviour as calling the default constructor
( with default arguements where required ). Along with this, keep the
option open to call constructors explicitly.
Ok, so here's another example:
def init(self):
print An __init__ method,
The compiler also calls the default arguement constructor
automatically, if such a constructor is provided for the base
class(es); but, this becomes a special case of what has been said by
Andrew Koenig.
So, it is NOT just the no arguement constructor that is automatically
called; note that the
I guess you are right.
--
http://mail.python.org/mailman/listinfo/python-list
Paul McNett wrote:
Sriek wrote:
(snip)
Similarly, why do we have to explicitly use the 'self' keyword
everytime?
This is closer to a wart, IMO,
I've always explicitelly used the (implied) 'this' pseudo-pointer in
Java, C++ etc. The wart is in all those languages that don't makes it
bruno modulix [EMAIL PROTECTED] wrote:
I've always explicitelly used the (implied) 'this' pseudo-pointer in
Java, C++ etc. The wart is in all those languages that don't makes it
mandatory IMHO !-)
And the correlary wart in Python is that the first argument to a
method is not required to be
bruno modulix wrote:
Paul McNett wrote:
Sriek wrote:
(snip)
Similarly, why do we have to explicitly use the 'self' keyword
everytime?
This is closer to a wart, IMO,
Here's one of the shorter threads discussing 'self'. I remember one
long running thread, but
Roy Smith a écrit :
bruno modulix [EMAIL PROTECTED] wrote:
I've always explicitelly used the (implied) 'this' pseudo-pointer in
Java, C++ etc. The wart is in all those languages that don't makes it
mandatory IMHO !-)
And the correlary wart in Python is that the first argument to a
method
Wow.. Andrew Koenig.. I found your name in many c++ books I read. Never
know you are hanging around in python python mailing-list.
(or perhaps python newsgroup, whatever it is)
Thanks for the explanation.
Andrew Koenig wrote:
Sakesun Roykiattisak [EMAIL PROTECTED] wrote in message
If you really want, you can customize the object system
to automatically call __init__, via a custom metaclass.
There is an example in my ACCU lectures (cooperative_init.py):
http://www.reportlab.org/~andy/accu2005/pyuk2005_simionato_wondersofpython.zip
Michele Simionato
--
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
++, 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
Sriek 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.
What do you mean by
Tim pointed out rightly that i missed out the most crucial part of my
question.
i should have said that __init__() is not called automatically only for
the inheritance hierarchy. we must explicitly call all the base class
__init__() fuctions explicitly.
i wanted a reason for that.
Thanks Tim
Paul McNett wrote:
Sriek wrote:
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.
[snip]
It is
22 matches
Mail list logo