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


Groups > comp.lang.python > #65151

Re: __init__ is the initialiser

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'mrab': 0.05; 'python)': 0.05; '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; 'sentence': 0.09; 'warn': 0.09; 'python': 0.11; '>the': 0.16; '__new__': 0.16; 'created.': 0.16; 'creation.': 0.16; 'finney': 0.16; 'operation.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'simpson': 0.16; 'succinct': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'basis,': 0.24; 'earlier': 0.24; 'header:X-Complaints-To:1': 0.27; "doesn't": 0.30; 'getting': 0.31; 'usually': 0.31; 'writes:': 0.31; 'supposed': 0.32; 'reader': 0.33; 'subject:the': 0.34; 'there': 0.35; 'explains': 0.36; 'false': 0.36; 'received:com.au': 0.36; 'so,': 0.37; 'clear': 0.37; 'ben': 0.38; 'convention': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'new': 0.61; 'skip:\xe2 10': 0.65; 'line,': 0.68; 'of:': 0.68; '8bit%:43': 0.74; 'special': 0.74; '100%': 0.77; '8bit%:46': 0.78; 'received:125': 0.84; 'step.': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ben Finney <ben+python@benfinney.id.au>
Subject Re: __init__ is the initialiser
Date Sat, 01 Feb 2014 10:47:42 +1100
References <52EC0E3C.5070900@stoneleaf.us> <20140131224507.GA5454@cskk.homeip.net>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host vmx15867.hosting24.com.au
X-Public-Key-ID 0xBD41714B
X-Public-Key-Fingerprint 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-gpg.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
Cancel-Lock sha1:cCF68WRn0m6+By9DkkiW7fEO8tA=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6231.1391212076.18130.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391212076 news.xs4all.nl 2968 [2001:888:2000:d::a6]:51141
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65151

Show key headers only | View raw


Cameron Simpson <cs@zip.com.au> writes:

> > On 01/31/2014 12:48 PM, MRAB wrote:
> > >The advantage of calling it the "initialiser" is that it explains
> > >why it's called "__init__".
>
> On this basis, would it suffice to change the opening sentence from:
>   Called when the instance is created.
>
> to
>   Called to initialise a new instance immediately after creation.
>
> ?
>
> This seems succinct while getting both "initialise" and "new" into the
> line, which makes it clear that there is a separate and earlier "new"
> step. (Conveniently overridable with __new__ :-)

It leaves a naive reader (who isn't yet familiar with the convention for
special names in Python) with the false implication that “__init__” is
usually called *manually*.

I would prefer it to be clear that “__init__” is called automatically,
*during* the constructor's operation. So, instead of:

    Called when the instance is created.

I suggest:

    Called automatically by the constructor “__new__” during instance
    creation, to initialise the new instance.

-- 
 \     “Why doesn't Python warn that it's not 100% perfect? Are people |
  `\         just supposed to “know” this, magically?” —Mitya Sirenef, |
_o__)                                     comp.lang.python, 2012-12-27 |
Ben Finney

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


Thread

Re: __init__ is the initialiser Ben Finney <ben+python@benfinney.id.au> - 2014-02-01 10:47 +1100

csiph-web