

Now lets compare this with: "hello world"ĭo you instantly know what happens? The string is also reversed, but was it just as easy to read? Of course complex pieces of code/logic are sometimes inevitable. Making the code very easy to read and understand But by given the function a logic name, we know what happensīy making a function, we can give the function a logic name, making it clear what is happening. We don’t need to understand the underlying implementation.

We now know that we will get: “dlrow olleh”. If we then have function which implements this reverse, then the function call looks like this: reverse("hello world") Lets say I have complex piece of code, for example to reverse a string. Logic of any given line or block of code?Īlso very important. These aren’t the only linting/formatting tools so have a shop around if you like. That’s a good jumping off point at the very least should you find a spot where you think it’s better to break from convention.

Having a look at the output of such formatting options will show you at least what a fair few people think is readable. I am a little curious as to why not books? Even if you don’t get a physical copy, the layout of books is designed for something like this and if nothing else having a series of examples tends to help a great deal.įor python specifically I think it’s worth looking into some of the tools that automate parts of this for you, linting tools like pylint, flake8 (mypy for type checking) and such will do basic code analysis and check for a number of common issues, both actual errors and silly things like unused variables or excess whitespace.Ī further option would be the automatic formatting tools like yapf, autopep8 and black which will format entire files/directories for you.
