Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #103890

Re: What arguments are passed to the __new__ method ?

From Rob Gaddi <rgaddi@highlandtechnology.invalid>
Newsgroups comp.lang.python
Subject Re: What arguments are passed to the __new__ method ?
Date 2016-03-02 17:57 +0000
Organization A noiseless patient Spider
Message-ID <nb79hd$joh$1@dont-email.me> (permalink)
References <56d5d043$0$632$426a74cc@news.free.fr> <djoms1F1q2aU2@mid.individual.net>

Show all headers | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

What arguments are passed to the __new__ method ? "ast" <nomail@invalid.com> - 2016-03-01 18:24 +0100
  Re: What arguments are passed to the __new__ method ? eryk sun <eryksun@gmail.com> - 2016-03-01 13:54 -0600
  Re: What arguments are passed to the __new__ method ? Terry Reedy <tjreedy@udel.edu> - 2016-03-01 15:27 -0500
  Re: What arguments are passed to the __new__ method ? eryk sun <eryksun@gmail.com> - 2016-03-01 15:09 -0600
  Re: What arguments are passed to the __new__ method ? "ast" <nomail@invalid.com> - 2016-03-02 10:23 +0100
    Re: What arguments are passed to the __new__ method ? Steven D'Aprano <steve@pearwood.info> - 2016-03-02 22:02 +1100
  Re: What arguments are passed to the __new__ method ? Peter Pearson <pkpearson@nowhere.invalid> - 2016-03-02 17:40 +0000
    Re: What arguments are passed to the __new__ method ? Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-03-02 17:57 +0000
      Re: What arguments are passed to the __new__ method ? Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-02 11:26 -0700

csiph-web