__init__ is the initialiser

Ethan Furman ethan at stoneleaf.us
Sat Feb 1 05:55:15 CET 2014

On 01/31/2014 08:35 PM, Chris Angelico wrote:
> On Sat, Feb 1, 2014 at 2:42 PM, Steven D'Aprano wrote:
>> Thus, two methods. __new__ constructs (creates, allocates) a new object;
>> __init__ initialises it after the event.
> Yes, but if you think in terms of abstractions, they're both just
> steps in the conceptual process of "creating the object".

> So maybe it's best to talk about the two methods collectively as
> "the constructor", and then let people call the two parts whatever
> they will.

> I do like the idea of calling __init__ the initializer. The downside
> of calling __new__ the constructor is that it'll encourage C++ and
> Java programmers to override it and get themselves confused

Why do we worry so about other languages?  If and when I go to learn C++ or Lisp, I do not expect their devs to be 
worrying about making their terminology match Python's.  Part of the effort is in learning what the terms mean, what the 
ideology is, the differences, the similarities, etc., etc..


More information about the Python-list mailing list