Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65151 > unrolled thread
| Started by | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| First post | 2014-02-01 10:47 +1100 |
| Last post | 2014-02-01 10:47 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: __init__ is the initialiser Ben Finney <ben+python@benfinney.id.au> - 2014-02-01 10:47 +1100
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2014-02-01 10:47 +1100 |
| Subject | Re: __init__ is the initialiser |
| Message-ID | <mailman.6231.1391212076.18130.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web