pylint woes

Christopher Reimer christopher_reimer at icloud.com
Sat May 7 14:52:23 EDT 2016


On 5/7/2016 9:51 AM, DFS wrote:
> Has anyone ever in history gotten 10/10 from pylint for a non-trivial 
> program?

I routinely get 10/10 for my code. While pylint isn't perfect and 
idiosyncratic at times, it's a useful tool to help break bad programming 
habits. Since I came from a Java background, I had to unlearn everything 
from Java before I could write Pythonic code. It might help to use an 
IDE that offers PEP8-compliant code suggestions (I use PyCharm IDE).

> That's about as good as it's gonna get!

You can do better.  You should strive for 10/10 whenever possible, 
figure out why you fall short and ask for help on the parts that don't 
make sense.

> pylint says "Consider using enumerate instead of iterating with range 
> and len"
>
> the offending code is:
> for j in range(len(list1)):
>   do something with list1[j], list2[j], list3[j], etc.

This code is reeking with bad habits to be broken. Assigning a throwaway 
variable to walk the index is unnecessary when Python can do it for you 
behind the scenes. As Chris A. pointed out in his post, you should use 
zip() to walk through the values of each list at the same time.

Thank you,

Chris R.




More information about the Python-list mailing list