pylint -- should I just ignore it sometimes?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Tue Oct 19 17:11:07 EDT 2010
On Tue, 19 Oct 2010 19:57:36 +0000, Seebs wrote:
> So, I'm messing around with pylint. Quite a lot of what it says is
> quite reasonable, makes sense to me, and all that.
>
> There's a few exceptions.
>
> One: I am a big, big, fan of idiomatic short names where appropriate.
> For instance:
> catch <something>, e:
That would be except, not catch.
> I don't want a long, verbose, name -- "e" is about as much in need of a
> long and descriptive name as the stereotypical "i" one would use as a
> loop index (in a language without iterators). Should I just ignore
> that, or is it really more Pythonic to say something like:
> catch KeyError,
>
exception_resulting_from_the_use_of_a_key_not_defined_for_the_dictionary_in_which_it_was_looked_up:
Well, that name is 98 characters, which means it's impossible to use it
without exceeding the 78 or 79 character per line limit, so I guess that
since there's no other alternative between 1 character and 98, you'll
just have to break down and ignore pylint.
> So am I going to be laughed out of the room if I just let a class have
> eight instance attributes, or use a short name for a caught exception?
Unfortunately, pylint is always right. Without exception. Like Microsoft
Word's grammar checker. As we all know, computers are much more capable
of capturing fine and subtle distinctions of meaning than we are, so we
should always follow their advice.
*wink*
Perhaps you should have a read of PEP 8, the recommended style guide.
http://www.python.org/dev/peps/pep-0008/
Take particular note of what it says about inconsistency.
--
Steven
More information about the Python-list
mailing list