Re: [Tutor] __new__ and __init__

2012-08-02 Thread Alan Gauld
On 01/08/12 15:28, rail shafigulin wrote: I'm trying to understand how to use the two methods. I know that __new__ is used to create an object, while __init__ to initialize. But I'm not sure what happens when I create an object. Use print statements to find out... >>> class C(object): ...

Re: [Tutor] __new__ and __init__

2012-08-01 Thread eryksun
On Wed, Aug 1, 2012 at 11:10 AM, Hugo Arts wrote: > On Wed, Aug 1, 2012 at 4:28 PM, rail shafigulin > > * small caveat: I'm entirely unsure of this, but I *think* if you create > CarModel with a metaclass that overrides __call__ you can change the way > __new__ and __init__ work? If anyone can co

Re: [Tutor] __new__ and __init__

2012-08-01 Thread Steven D'Aprano
On 02/08/12 01:10, Hugo Arts wrote: * small caveat: I'm entirely unsure of this, but I *think* if you create CarModel with a metaclass that overrides __call__ you can change the way __new__ and __init__ work? If anyone can confirm this, be my guest. Correct. Metaclasses can essentially change

Re: [Tutor] __new__ and __init__

2012-08-01 Thread Steven D'Aprano
On 02/08/12 00:28, rail shafigulin wrote: Hello everyone. I'm trying to understand how to use the two methods. I know that __new__ is used to create an object, while __init__ to initialize. But I'm not sure what happens when I create an object. I found the following code in the book (Python 3 O

Re: [Tutor] __new__ and __init__

2012-08-01 Thread Hugo Arts
On Wed, Aug 1, 2012 at 4:28 PM, rail shafigulin wrote: > Hello everyone. > > I'm trying to understand how to use the two methods. I know that __new__ > is used to create an object, while __init__ to initialize. But I'm not sure > what happens when I create an object. > > I found the following code

[Tutor] __new__ and __init__

2012-08-01 Thread rail shafigulin
Hello everyone. I'm trying to understand how to use the two methods. I know that __new__ is used to create an object, while __init__ to initialize. But I'm not sure what happens when I create an object. I found the following code in the book (Python 3 Object Oriented Programming by Dusty Phillips