Multiple inheritance, super() and changing signature
steve at pearwood.info
Thu Jun 2 13:36:14 EDT 2016
On Thu, 2 Jun 2016 06:22 pm, Lawrence D’Oliveiro wrote:
> On Wednesday, June 1, 2016 at 8:02:14 AM UTC+12, Ben Finney wrote:
>> (Note that ‘__init__’ is not a constructor, because it operates on the
>> *already constructed* instance, and does not return anything.
> Believe it or not, that *is* what “constructor” means in every OO
I don't believe it.
C# is an OO language, and it distinguishes constructors and initialisers:
(although they don't seem to mean quite the same as what they mean in
Objective C is also an OO language, and it calls `init` the initializer:
The documentation doesn't specifically give a name to the `alloc` method,
but since it allocates memory for the instance, "allocator" is the obvious
And `new` merely calls alloc, then init. (Although I'm lead to understand
that in older versions of Cocoa, `new` handled both allocation and
Smalltalk, the grand-daddy of OOP languages, doesn't even have constructors
(at least not in the modern OOP sense):
Any method can be used to create an object, there is no reserved name for
such a method.
Python is an OO language, what does it say?
The glossary doesn't define *either* constructor or initialiser (or
and the docs for __new__ and __init__ don't refer to them by either name:
The docs do refer to the "object constructor expression", but that's the
call to the class, not the special method. And the term "initialiser"
or "initializer" is frequently used by Python developers to refer to
> Technically it should be called the “initializer”, but
> “constructor” is the accepted term for the special method that is called
> to initialize a newly-allocated class instance.
Not in Python circles it isn't.
But since the constructor/initialiser methods are so closely linked, many
people are satisfied to speak loosely and refer to "the constructor" as
either, unless they specifically wish to distinguish between __new__ and
More information about the Python-list