Re: __init__ function problem

2006-11-07 Thread Colin J. Williams
Carl Banks wrote: > kelin,[EMAIL PROTECTED] wrote: >> It says the __init__ is called immediately after an instance of the >> class is created. What dose "immediately" mean? >> And what is difference between the init method and the constructor in >> Java? > > For all intents and purposes, __init__

Re: __init__ function problem

2006-11-07 Thread kelin,[EMAIL PROTECTED]
Hi, I've read all of this. And I am clear about it. Thanks all. Best Regards! Gabriel Genellina wrote: > At Tuesday 7/11/2006 21:47, Jia Lu wrote: > > > > In Python, the real constructor is called __new__, > > > > Carl Banks > > > >But the code below won't invoke __new__: > > Is this a question, o

Re: __init__ function problem

2006-11-07 Thread Gabriel Genellina
At Tuesday 7/11/2006 21:47, Jia Lu wrote: > In Python, the real constructor is called __new__, > > Carl Banks But the code below won't invoke __new__: Is this a question, or just for making things more and more confusing to beginners? class Test: def __new__(self, value): prin

Re: __init__ function problem

2006-11-07 Thread Jia Lu
> In Python, the real constructor is called __new__, > > Carl Banks But the code below won't invoke __new__: [CODE] class Test: def __new__(self, value): print "__new__",value def __init__(self,value): print "__init__",value x = Test("testing") [/CODE] -- http://mail.p

Re: __init__ function problem

2006-11-07 Thread Carl Banks
kelin,[EMAIL PROTECTED] wrote: > It says the __init__ is called immediately after an instance of the > class is created. What dose "immediately" mean? > And what is difference between the init method and the constructor in > Java? For all intents and purposes, __init__ is a constructor. It isn't

Re: __init__ function problem

2006-11-07 Thread babui
Steven D'Aprano ha escrit: > Once the __new__ method creates the instance and returns, before anything > else happens, the instance's __init__ method is called. This only happens when the object created by __new__ isinstance of the class invoked in the creation statement, that is: s=MagicStr("l

Re: __init__ function problem

2006-11-07 Thread Steven D'Aprano
On Tue, 07 Nov 2006 05:26:07 -0800, kelin,[EMAIL PROTECTED] wrote: > Hi, > > Today I read the following sentences, but I can not understand what > does the __init__ method of a class do? Play around with this class and see if it helps: class MagicStr(str): """Subclass of str with leadi

Re: __init__ function problem

2006-11-07 Thread Duncan Booth
"kelin,[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Today I read the following sentences, but I can not understand what > does the __init__ method of a class do? > __init__ is called immediately after an instance of the class is > created. It would be tempting but incorrect to call this the > c

__init__ function problem

2006-11-07 Thread kelin,[EMAIL PROTECTED]
Hi, Today I read the following sentences, but I can not understand what does the __init__ method of a class do? __init__ is called immediately after an instance of the class is created. It would be tempting but incorrect to call this the constructor of the class. It's tempting, because it looks li