|
|
|
|
|
by jakewins
429 days ago
|
|
There is no contradiction between “constructors cannot fail” and “fail early”, nobody is arguing the constructor should do fallible things and then hide the failure. What you should do is the fallible operation outside the constructor, before you call __init__, then ask for the opened file, socket, lock, what-have-you as an argument to the constructor. Fallible initialisation operations belong in factory functions. |
|