4 ms·
What about just liberal use of ‘assert‘ throughout the codebase. These are good to use in production code (not just in tests). And give you a means of defensive
by bradwood 4y ago
What about just liberal use of ‘assert‘ throughout the codebase. These are good to use in production code (not just in tests). And give you a means of defensively coding and forcing errors if, for example column names are missing?
- TheAlchemist 4y agoThat wouldn't solve the problems described, would it ? If a column is missing, the code would crash anyway - that's not my issue. My issue is more about understanding and maintainability of the code, as well as ease of coding. I've found this, which seems quite close to be usable: https://strictly-typed-pandas.readthedocs.io/en/latest/ https://strictly-typed-pandas.readthedocs.io/en/latest/
- bradwood 4y agoYou may find lots of ide tools, type hinting systems and so on. But these are a bit like crutches IMHO. You don't need them to make maintainable code. If your functions are small, pure, well-tested then you are good. Small functions are much more maintainable, testable,easy to reason about, etc. So rather than worrying about code completion and type hints. Just try to work in a more functional style. It will pay big dividends.
- TheAlchemist 4y agoAgree on small functions, although it still doesn't really solve my perceived problem. Would you know some good python applications using pandas in that way that I could look at to get a better idea ?