[Tutor] Is self.__init__() call bad style?

Alan Gauld alan.gauld at freenet.co.uk
Fri Apr 22 13:02:47 CEST 2005


> I am working on a script at the moment, in which I seem to need to
> re-initialise a class instance from within some of its methods.
Before I go
> too much further down this route - could anyone comment on whether
the call
> self.__init__() is in itself considered bad style or 'unpythonic'?

NO its perfectly normal OOP style, in Python or otherwise.

> For instance, is it better to create a 'reset' method, which is
called both
> by __init__ and by the methods which are wanting to force a
> re-initialisation?

Some folks seem to prefer that technique (and it's necessary in
Java/C++
where the constructor cannot be called directly) but it adds very
little
benefit IMHO. init() is for initialisation and if you are sure you
want
to reset everything to default then why not use it.

Alan G.



More information about the Tutor mailing list