Subsurface Syntax

Subsurface Syntax

5 Essential Tips to Improve the Readability of Your Python Code

Improving your Python Code Through Documentation, Type Hinting and Proper Variable Names

Andy McDonald's avatar
Andy McDonald
Jul 22, 2022
∙ Paid

Improving your Python Code Through Documentation, Type Hinting and Proper Variable Names

Photo by Clément Hélardot on Unsplash

Do you often look back at some code you wrote 6 months ago and scratch your head and wonder what this mess is? Or have you been passed a project that has been worked on by someone else and struggle to know where to start? If so you are not alone.

There are a number of ways in Python to help you understand the inner workings of your code, so that when you come back to it, it should be much easier to carry on where you left off.

As an example, we may end up with code that looks a lot like the one in the image below. It is not the worst, however, there are a few things we need to expand on such as:

  • What does f and d stand for in the load_las_file function?

  • Why are we checking the result in the clay function?

  • What types are these functions looking for? Floats? DataFrames?

Keep reading with a 7-day free trial

Subscribe to Subsurface Syntax to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2026 Andy McDonald · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture