Over the years, I have seen and worked on numerous Python scripts within the domains of geosciences and petrophysics. In that time, I've seen (and also written about) a variety of coding styles, from well-organized, well-documented code to everything in a single Python file with little to no organization. With the latter, it can be difficult to maintain, debug, and understand when the code is reviewed several months later. The purpose of writing the code will often dictate the style used.
If we are creating a script that may be used once or twice or are working under strict pressures and time constraints, we may not be able to make things as nice and organized as we would like. However, if we are creating code that we will use multiple times or are deploying to other users, and if we have time, we may want to structure the code or application in a way that makes it suitable for later expansion. This can save you time and headaches when reviewing your code and also avoids the dilemma of forgetting what the code does or what it was intended to do.
As a geoscientist, coding may not be part of your natural training. However, he may have seen and heard colleagues and friends talk about the apps they have created, which inspired him to give it a try.
In this article, I'll share five tips that I've learned over the years that have improved my geoscience Python applications. I do this in the hope that they will also help those venturing into the world of Python and machine learning for the first time.
These tips are also equally applicable to anyone who is not a geoscientist and is just starting to learn Python.
When creating Python applications at the beginning of your journey, it can be convenient and easy to keep all your code in a single folder. However, as your project begins to grow in size and complexity, it can become difficult to maintain and navigate through your codebase.