__init__ explanation please

Hrvoje Niksic hniksic at xemacs.org
Mon Jan 14 11:29:16 EST 2008


Mel <mwilson at the-wire.com> writes:

>> I don't understand the purpose of this "correction".  After all,
>> __init__ *is* the closest equivalent to what other languages would
>> call a constructor.  
>
> Nevertheless, __init__ doesn't construct anything.

Only if by "construct" you mean "allocate".  __init__ starts out with
an empty object and brings it to a valid state, therefore
"constructing" the object you end up with.  That operation is exactly
what other languages call a constructor.



More information about the Python-list mailing list