__init__ explanation please

Ben Finney bignose+hates-spam at benfinney.id.au
Mon Jan 14 17:20:17 EST 2008


Hrvoje Niksic <hniksic at xemacs.org> writes:

> Wildemar Wildenburger <lasses_weil at klapptsowieso.net> writes:
> > __init__() /initializes/ an instance (automatically after
> > creation). It is called, /after/ the instance has been constructed
> 
> I don't understand the purpose of this "correction".  After all,
> __init__ *is* the closest equivalent to what other languages would
> call a constructor.

No. That would be '__new__', which actually constructs the instance,
and actually returns it to the caller. '__init__' does neither of
those.

It so happens that, in Python, one usually overrrides the initialiser
and not the constructor. Thus, the confusion is understandable, but
still regrettable and avoidable.

-- 
 \         "My, your, his, hers, ours, theirs, its. I'm, you're, he's, |
  `\                         she's, we're, they're, it's." —anonymous, |
_o__)                                            alt.sysadmin.recovery |
Ben Finney



More information about the Python-list mailing list