5 ESSENTIAL KEYS TO EMPOWER YOUR RELATIONSHIPS

Relationship building whether it is a business or individual relationship takes trust, responsibility and compelling abilities to be effective relationship building. 2. Have you at any point asked…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Improving python code quality using Pylint and Black

Code is written to be read. Even when you are the sole developer on a project, you will need to read your code in the future to maintain it. You should invest an equal amount of time in solving the problem and writing readable code.

Python community has invested in rules that standardize how programmers write code. This has come in the form of Pep8. While we are grateful this neat tool exists, it is long and easy to ignore, especially by inexperienced programmers. There has been a number of tools developed to enforce the Pep8 standards. They make it easier to access the rules and change the rules when they are a hindrance to problem-solving. Ever since my team embraced Pylint and black, code reviews become more effective, they focus more on scalability than how code is written.

As a python programmer, Black is your friend. Black is loving, nurturing, and kind. Think about it, Black goes through your code, and corrects what you ‘f*cked up’. After I finish writing my module and running unit tests on them, the next thing for me is to run Black. Let me take you through the steps:

Add the following code to your main.py file:

Note that your code runs just fine, returning ‘hello Sam’ when you run

Results to:

And your code looks like this:

Now notice that the spacing is different, much more elegant, and neat.

Results to this:

The results:

The work is now to improve your code until it looks good. Google your errors if you want to learn more about them before you make edits. After correcting all the errors Pylint complained about you will get this:

Final code:

Add a comment

Related posts:

Introduction to the Being Well Publication

Got a health problem? The answer is not to consult Dr. Google or Dr. Wikepedia. The internet is full of health information, but it is challenging to know who you can trust. To help readers find…

Best Decision in 2020

What was your best decision in 2020? Most likely you would pick the decisions that led to success, rather than failure. If you don’t play football anymore, you might still count your decision to play…

Hyperledger Fabric

In the first part of this series we discussed what the Hyperledger project is and all of the different frameworks and tools it hosts. In this post I will explore the Hyperledger Fabric and…