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

Kent Johnson kent37 at tds.net
Fri Apr 22 12:18:09 CEST 2005


Barnaby Scott wrote:
> 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'?
> 
> 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?

Personally I would make a reset() method, the intent is clearer and it is less prone to breakage if 
for some reason you change __init__ later.

Kent



More information about the Tutor mailing list