Writing better Python code
Image by https://www.pexels.com/@mikhail-nilov/ When we write code in any programming language, we tend to look into how code is written in the language. There are some guidelines and conventions that can help us to write better code and more readable code. There is even a term created for this in Python and it is Pythonic . In this blog, I share some of my points of view on writing better Python code. 1. Wildcards Imports Sometimes, when we look at a function and we do not know where it is imported from. For example # bad practice to import all from math import * print(ceil(0.6)) This one is obvious however it is not when there are many imports and many lines of code in a file. A better way is # good practice to import what we need from math import ceil print(ceil(0.6)) 2. Unnecessary use of True and False This is not particular to writing code in Python as we have seen this in other programming languages too. names = ["ann", "beth", "candy", "d