Carl Banks wrote:

So what is the point of using __new__?

.__new__ creates new objects. It also inializes 'immutable' objects.

It's mostly for types written in C, or for subclassing types written
in C.

Specifically, for subclassing immutable classes where one wants initialization behavior different from that provided by the superclass.

> Advanced programmers can take advantage of it to do some
interesting things, but most of the time __init__ suffices.

Initialization of mutables should be done in .__init__. Most user-defined classes define mutables.

Terry Jan Reedy


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to