[Tutor] __init__

Alan Gauld alan.gauld at yahoo.co.uk
Tue Aug 30 16:21:06 EDT 2016


On 30/08/16 12:50, eryksun wrote:
> On Tue, Aug 30, 2016 at 9:09 AM, Alan Gauld via Tutor <tutor at python.org> wrote:
>> new() that sets up the memory then calls init(). So init is
>> only used to initialise the object after it has been
>> constructed.
>
> __new__ and __init__ are called by the metaclass __call__ method.
> __init_ is called if __new__ returns an instance of the class.

Quite so, but I didn't want to bend brains too much
by mentioning metaclasses! They are confusing enough
for experienced programmers let alone the typical
tutor subscriber!

Alan G




More information about the Tutor mailing list