When you start your first Python project, the code that you or your team members are going to write should be consistent with the standards defined so that your code is readable. This will make it easier for anyone who comes after you, to develop the application, to understand the code.
We are going to use
pycodestyle to check whether our not our code follows the coding standards. Earlier our module was named as pep8, but to avoid confusion, it was renamed to
This is a very easy module to use. First, install the module by running the following command:
pip install pycodestyle
After this, you can run the command below to check any Python file for standard checking:
Run the below code to see where this module identified the standard violation. When you click the “Run” button, the command is run internally:
Below is a simple code that prints the current working directory:
import os, sys def printDirectory(): print(os.getcwd()) printDirectory()
After running the code, you can see that we have not incorporated all the Python coding standards; so, we should make changes to our code accordingly to make it more readable.
View all Courses