2 ms·
Python modules are basically a singleton class. It's somewhat unique among languages (JS has this too). Makes it so you can "unit test" modules without actuall
by geenat 5y ago
Python modules are basically a singleton class. It's somewhat unique among languages (JS has this too).
Makes it so you can "unit test" modules without actually using a Python Class. I see the Python Class as a way to get a "module within a module".
Nice side effect of Python modules as singletons: The "self." is implicit to the scope of the module- This makes them a joy to write.
In most other languages, yeah, you'll want some form of encapsulation so you can write tests.
Type checking can cut down on the amount of tests you need to write, but you're continually paying for it with dev time. This is a decision that needs to be made depending on what the project is, whos working on it. If I'm on a team with a lot of new people who will try shoving data where it shouldn't go, yes, gonna force type checking and take the velocity hit.