News for hackers. Stuff that matters.
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.
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

Re:Frankenstein's `__init__` by rcxdude on Saturday April 19, 2025 @07:12PM (#43740205)
Init isn't really special (especially compared to e.g. __new__). It has no special privileges, it's just a method that is called when you construct an instance of the class.