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


Groups > comp.lang.python > #65146

Re: __init__ is the initialiser

Date 2014-02-01 09:45 +1100
From Cameron Simpson <cs@zip.com.au>
Subject Re: __init__ is the initialiser
References <52EC0E3C.5070900@stoneleaf.us>
Newsgroups comp.lang.python
Message-ID <mailman.6226.1391208314.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 31Jan2014 12:57, Ethan Furman <ethan@stoneleaf.us> wrote:
> On 01/31/2014 12:48 PM, MRAB wrote:
> >On 2014-01-31 19:52, Ned Batchelder wrote:
> >>Why can't we call __init__ the constructor and __new__ the allocator?
> >
> >The advantage of calling it the "initialiser" is that it explains why
> >it's called "__init__".
> 
> Hm, yes, good point.  Also, __init__ initializes so it is a good choice.   Ignore the names comment in my previous post.

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__ :-)

Cheers,
-- 
Cameron Simpson <cs@zip.com.au>

Don't have awk? Use this simple sh emulation:
    #!/bin/sh
    echo 'Awk bailing out!' >&2
    exit 2
- Tom Horsley <tahorsley@csd.harris.com>

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


Thread

Re: __init__ is the initialiser Cameron Simpson <cs@zip.com.au> - 2014-02-01 09:45 +1100

csiph-web