Member-only story

10 Super Useful Tips For Readable Python Script

Python tips for beginners

Sruthi Korlakunta
2 min readJan 20, 2023
Photo by Artem Sapegin on Unsplash

Python is known for its readability and simplicity. More and more users are taking to python as it slowly replaces traditional analytics tools because of the ease and flexibility in data manipulation it offers.

However, as you write more complex code, it’s easy to fall into bad habits that can make your code harder to read and understand. Here are 10 things to keep in mind when cleaning your Python code:

1. Use meaningful variable names

Avoid using single-letter variable names or generic names like “temp” or “list”. Instead, use meaningful names that clearly describe the purpose of the variable.

2. Keep lines short

Limit the length of your lines to around 79 characters. This makes it easier to read your code on smaller screens and helps prevent horizontal scrolling.

3. Use white space:

Use blank lines and indentation to separate different sections of your code and make it easier to read.

4. Use docstrings

Use docstrings to document your code and explain what different functions or classes do.

5. Use comments

--

--

Sruthi Korlakunta
Sruthi Korlakunta

Written by Sruthi Korlakunta

I write on tech, books, and lifestyle. | Data analyst | Made human by all the people who love me.

Responses (1)