Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65151
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Subject | Re: __init__ is the initialiser |
| Date | 2014-02-01 10:47 +1100 |
| References | <52EC0E3C.5070900@stoneleaf.us> <20140131224507.GA5454@cskk.homeip.net> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6231.1391212076.18130.python-list@python.org> (permalink) |
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
Re: __init__ is the initialiser Ben Finney <ben+python@benfinney.id.au> - 2014-02-01 10:47 +1100
csiph-web