3 ms·
I like the idea, but it feels a bit heavy handed outside of a very large team. I think the first step here is to get away from the assumption that importing a
by jbmsf 7y ago
I like the idea, but it feels a bit heavy handed outside of a very large team.
I think the first step here is to get away from the assumption that importing a module will have "interesting" side effects. This is not only a problem with Python...
I tend to create mini "dependency injection" frameworks that create a pattern for loading module code at some point well after import. This patterns tends to reduce to wrapping whatever code you have in the module in a function/closure instead of just running whenever.
Again, I like the idea of enforcing constraints with code, but I don't think it's a substitute for educating developers to avoid certain patterns and giving them infrastructure that makes the alternative easy.