Python Forum

Full Version: Lint and private var names
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been using _ to start private variables but I've also just found tried out pylint and it complains that the private vars are not snake-case.

I don't really care if I use snake-case or _ style myself but I want to make the code readable for others (which is part of the reason for trying out pylint).

Is there a way to make pylint think leading _'s are OK or is snake-case fine for private variable names? If snake-case then what to use for public variables?

Inquiring ignoramuses want to know!

Thanks
I use pylint and it doesn't complain. My guess is you are using the leading underscore incorrectly. You use a leading underscore to indicat that a CLASS ATTRIBUTE should be treated like it is private. Variables need no such convention because they really are private. You cannot access a variable from outside its scope.

Can you provide an example of code where pylint issues the warning?