Pylint prefers list comprehension over filter...

Chris Angelico rosuav at gmail.com
Sat May 7 17:46:17 EDT 2016


On Sun, May 8, 2016 at 7:35 AM, Stephen Hansen <me at ixokai.io> wrote:
> On Sat, May 7, 2016, at 12:17 PM, Christopher Reimer wrote:
>> On 5/5/2016 6:37 PM, Stephen Hansen wrote:
>> > On Thu, May 5, 2016, at 06:26 PM, Christopher Reimer wrote:
>> >> Which is one is correct (Pythonic)? Or does it matter?
>> > First, pylint is somewhat opinionated, and its default options shouldn't
>> > be taken as gospel. There's no correct: filter is fine.
>>
>> Since the code I'm working on is resume fodder (i.e., "Yes, I code in
>> Python! Check out my chess engine code on GitHub!"), I want it to be as
>> Pythonic and PEP8-compliant as possible. That includes scoring 10/10
>> with pylint. Never know when an asshat hiring manager would reject my
>> resume out of hand because my code fell short with pylint.
>>
>> For my purposes, I'm using the list comprehension over filter to keep
>> pylint happy.
>
> Bear in mind, when I say, "Pylint is opinionated", I mean the tool --
> especially in its default configuration -- has its own opinion of what
> is good style, and *I think its wrong on a number of points*.

Agreed. The OP has already run into this, and disabled some checks;
the logical next step is to stop treating a 10/10 score as mandatory.

> Its fine to use, but I'd read over PEP8 (the document, not the tool) and
> apply style guide recommendations thoughtfully, not mechanically.

Definitely. It's times like this that I'm really annoyed by the abuse
of the name "pep8" to mean the tool, especially since it's not
perfectly matched to the document (notably, it can't encode the
flexibilities, so it comes out as rigid).

Tools like this can be incredibly useful. But they are TOOLS, and the
code belongs to you. They are not your masters.

ChrisA



More information about the Python-list mailing list