Re: __init__() not called automatically

2005-05-27 Thread Simon Brunning
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

Re: __init__() not called automatically

2005-05-26 Thread Sakesun Roykiattisak
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

Re: __init__() not called automatically

2005-05-26 Thread Sriek
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

Re: __init__() not called automatically

2005-05-26 Thread Sriek
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.

Re: __init__() not called automatically

2005-05-26 Thread Jeremy Sanders
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,

Re: __init__() not called automatically

2005-05-26 Thread John Roth
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

Re: __init__() not called automatically

2005-05-26 Thread Dan Sommers
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/ --

Re: __init__() not called automatically

2005-05-26 Thread Andrew Koenig
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

Re: __init__() not called automatically

2005-05-26 Thread Steven Bethard
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,

Re: __init__() not called automatically

2005-05-26 Thread Sri Charan
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

Re: __init__() not called automatically

2005-05-26 Thread Sri Charan
I guess you are right. -- http://mail.python.org/mailman/listinfo/python-list

Re: __init__() not called automatically

2005-05-26 Thread bruno modulix
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

Re: __init__() not called automatically

2005-05-26 Thread Roy Smith
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

Re: __init__() not called automatically

2005-05-26 Thread John Abel
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

Re: __init__() not called automatically

2005-05-26 Thread Bruno Desthuilliers
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

Re: __init__() not called automatically

2005-05-26 Thread Sakesun Roykiattisak
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

Re: __init__() not called automatically

2005-05-26 Thread Michele Simionato
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 --

__init__() not called automatically

2005-05-25 Thread Sriek
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

Re: __init__() not called automatically

2005-05-25 Thread Tim Leslie
++, 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

Re: __init__() not called automatically

2005-05-25 Thread Paul McNett
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

Re: __init__() not called automatically

2005-05-25 Thread Sriek
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

Re: __init__() not called automatically

2005-05-25 Thread Steven Bethard
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