It is sometimes wise to use __init__ as an initialization method for an existing object, that is:
class A(): def __init__(self, x): self.x = x def set_state_from_file(self, file): x = parse_file(file) self.__init__(x)
As an alternative to this implementation, I see the following:
class A(): def __init__(self, x): self.init(x) def init(self, x): self.x = x def set_state_from_file(self, file): x = parse_file(file) self.init(x)
It seems to me that this is an overly complicated code. Are there any recommendations on this situation?
python initialization design-patterns pep8
Sklavit
source share