Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '*args,': 0.09; 'constructor': 0.09; 'creation,': 0.09; 'instance.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'type,': 0.09; 'def': 0.12; 'jan': 0.12; '**kwds)': 0.16; '**kwds):': 0.16; '[1].': 0.16; '__init__,': 0.16; '__new__': 0.16; 'constructor.': 0.16; 'created.': 0.16; 'finney': 0.16; 'operation.': 0.16; 'presume': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'basically': 0.19; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'this:': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'class': 0.32; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'something': 0.35; 'but': 0.35; 'so,': 0.37; 'clear': 0.37; 'ben': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'new': 0.61; 'received:173': 0.61; 'skip:\xe2 10': 0.65; 'of:': 0.68; '8bit%:43': 0.74; '8bit%:46': 0.78; 'ethan': 0.84; 'furman': 0.84; 'plugins': 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: __init__ is the initialiser Date: Fri, 31 Jan 2014 21:40:32 -0500 References: <52EC0E3C.5070900@stoneleaf.us> <20140131224507.GA5454@cskk.homeip.net> <85ob2rhfxd.fsf@benfinney.id.au> <52EC3C14.8080806@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-173-75-254-207.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: <52EC3C14.8080806@stoneleaf.us> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391222450 news.xs4all.nl 2829 [2001:888:2000:d::a6]:47945 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65168 On 1/31/2014 7:13 PM, Ethan Furman wrote: > On 01/31/2014 03:47 PM, Ben Finney wrote: >> >> I would prefer it to be clear that =E2=80=9C__init__=E2=80=9D is calle= d automatically, >> *during* the constructor's operation. So, instead of: >> >> Called when the instance is created. >> >> I suggest: >> >> Called automatically by the constructor =E2=80=9C__new__=E2=80=9D= during instance >> creation, to initialise the new instance. > > But __new__ does not call __init__, type does [1]. If the class is an instance of type, it is type.__call__, >>> tuple.__call__ I presume it is basically something like this: class type: def __call__(self, *args, **kwds): instance =3D self.__new__(cls, *args, **kwds) self.__init__(instance, *args, **kwds) return instance =2E__new__ and .__init__ are the plugins used by the true class instance = constructor. --=20 Terry Jan Reedy