messages from pylint - need some reasoning

GHUM haraldarminmassa at
Fri Oct 17 09:59:16 CEST 2008


I am pylinting some software of mine.

Now pylint throws messages, and I know of pylint --help-msg to get
some more text. What is missing out are explanation, WHY some things
are bad, so I am searching for explanations and ways to improve my

1st) "to many local variables"
I searched big G, and found: many local variables make it harder to
refactor, as all those variables will have to be passed to the
factored-out function. Even worse when the local variables are
mutable, and have to be passed back.

Similiar explanations I am searching for

2nd) "to many statements (in function / method)
okay, shorter functions are easier to grasp. Is there any more

3rd) space before operators, space after operators, space after ","
that's just readability, or is there some deaper reasoning?

4th) maximum line length
yeah, more then 80 chars suck when outputting to punching cards; but
any 21century reason for this default? (can and have made it higer)

5th) "Too many branches"
"Used when a function or method has too many branches, making it hard
to follow."

So what is the preferred way of repairng this?

Especially if the branches are something like:

if checkforcondition1():
    # inlinecode
    # to handlecondition1

if checkforcondition2():
    # inlinecode
    # to handlecondition1


and multiple conditions can be present at the same time.

Something like mytodolist=[ (tester1, handler1), (tester2,
handler2), ...] and

for tester, handler in mytodolist:
    if tester(situation):

would get rid of the branches; BUT... I cannot see how that is really
easier to follow.

Who can give me some hints to improve my code or arguments to switch
of that warnings?

best wishes,


More information about the Python-list mailing list