What arguments are passed to the __new__ method ?
Rob Gaddi
rgaddi at highlandtechnology.invalid
Wed Mar 2 12:57:01 EST 2016
Peter Pearson wrote:
> On Tue, 1 Mar 2016 18:24:12 +0100, ast wrote:
>>
>> It's not clear to me what arguments are passed to the
>> __new__ method. Here is a piece of code:
>>
>>
>> class Premiere:
>>
>> def __new__(cls, price):
>> return object.__new__(cls)
>>
>> def __init__(self, price):
>> pass
> [snip]
>
> Of course, maybe you don't need to define a __new__ method at all.
> Personally, I find that __init__ suffices for my simple needs.
>
I tend to need __init__ on about half of the classes I write. I think
I've needed __new__ all of twice in the years I've been writing Python.
--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order. See above to fix.
More information about the Python-list
mailing list