Re:Frankenstein's `__init__`
by exe34 on Saturday April 19, 2025 @01:39PM
(#43737978)
no thanks, that's how we end up with FactoryFactory. If the work needs to be done upon startup, then it needs to be done. if it is done in response to a later event, then it been done later.
[ Parent
| on HN ]
Re:Frankenstein's `__init__`
by duncanfwalker on Saturday April 19, 2025 @02:12PM
(#43738233)
For me the point is that __init__ is special - it's the language's the way to construct an object. If we want to side-effecting code we can with a non-special static constructor like
class Foo @classmethod def connect(): return Foo()._connect()
The benefit is that we can choose when we're doing 1) object construction, 2) side-effecting 3) both. The downside is client might try use the __init__() so object creation might need to be documented more than it would otherwise