pylint woes
DFS
nospam at dfs.com
Sat May 7 23:38:24 EDT 2016
On 5/7/2016 2:52 PM, Christopher Reimer wrote:
> 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.
10/10 on pylint isn't better. It's being robotic and conforming to the
opinions of the author of that app.
In fact, I think:
import os, sys, time, socket
is much more readable than, and preferable to,
import os
import sys
import time
import socket
but pylint complains about the former.
> You should strive for 10/10 whenever possible,
nah
> figure out why you fall short and ask for help on the parts that don't
> make sense.
I actually agree with ~3/4 of the suggestions it makes. My code ran
fine before pylint tore it a new one, and it doesn't appear to run any
better after making various fixes.
But between you clp guys and pylint, the code is definitely improving.
>> 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.
Don't you think python also allocates a throwaway variable for use with
zip and enumerate()?
> As Chris A. pointed out in his post, you should use
> zip() to walk through the values of each list at the same time.
Yeah, zip looks interesting. I just started using python a month ago,
and didn't know about zip until pylint pointed it out (it said I
redefined a builtin by using 'zip' as a list name).
Edit: I already put zip() it in place. Only improvement I think is it
looks cleaner - got rid of a bunch of [j]s.
> Thank you,
>
> Chris R.
No, thank /you/,
DFS
More information about the Python-list
mailing list