Much of the python code that I wrote today were a couple of the chapter examples in the Udemy Ultimate Python Programming Course. However, having discovered Pylint, I went back and coded up the examples in the chapters that I covered (6 and 7) and made them pass pylint tests.
The most valuable exercise was the ‘python calculator’:
The example basically shows two of the basic programming constructs in Python, the while loop and the if-elif-else construct(s). However, when I ran this again Pylint to test the syntax there were a couple things that needed to be changed:
A docstring needs to be added at the beginning, explaining what the code is/does.
All constants in the code should be capitalized.
The exercise used parentheses around the print statements- those are discouraged in PEP-8 python
Indentation should be 4 spaces instead of 2
The break command should not use a semicolon at the end
I think that this exercise was more valuable in the sense of learning pylint, rather than the basic constructs of the language- those I already know. Pylint is explicit on how your syntax should look. This one pass the pylint test with a 10/10. Perfect.