Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not really an OOP or Python defender, and generally agree that this type of constructor is inscrutable, frustrating, and quite common in the Python ecosystem.

That said, I would not consider default mock values in a constructor to be good OOP. In general, "new"ing things in a constructor IMO is a no-go and makes for harder testing and confusing behavior.

At the end of the day I'm not even sure why this class supports mock behavior. I'd expect two separate classes with divorced implementations, instead of an if statement on a boolean param.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: