tags:

views:

176

answers:

1

I have a module-level variable in my Python 2.6 program named "_log", which PyLint complains about:

C0103: Invalid name "_log" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)

Having read this answer I understand why it's doing this: it thinks the variable is a constant and applies the constant regex. However, I beg to differ: I think it's a variable. How do I tell PyLint that, so it doesn't complain? How does PyLint determine whether it's a variable or a constant - does it just treat all module-level variables as constants?

+5  A: 
# pylint: disable-msg=C0103

Put it in the scope where you want these warnings to be ignored.

IIRC it is true that pylint interprets all module-level variables as being 'constants'.

ChristopheD
Thanks. I also added `# pylint: enable-msg=C0103` afterwards so that the rest of the code still gets checked.
Evgeny
Note that putting it at the end of a line of code should also just disable this message for this particular line (no reenable needed then).
ChristopheD
Excellent, I didn't know that, either. Thanks again.
Evgeny