pylint #33617 single underscores and protected methods [rejected]
using/subclassing a class like collections.namedtuple and then calling its _make method causes pylint to emit a warning 'access to protected member'. pep8 calls a single leading underscore a 'weak internal use' indicator; while this is the case with collections.namedtuple, in fact the leading underscore in collections.namedtuple is designed to avoid naming conflicts. is this a poor naming decision for the stdlib collections.namedtuple, or something pylint should not throw warnings out about? | |
priority | normal |
---|---|
type | bug |
done in | <not specified> |
load | 0.000 |
load left | 0.000 |
closed by | <not specified> |
Comments
-
2011/08/01 14:22, written by anon
add commentThe Python documentation does have examples of using _name or even __name when designing for inheritance (http://docs.python.org/dev/tutorial/classes#private-variables). Underscored attributes are sometimes meant for external use, but the rest of the time the warning is right, so the problem is that there is no way for a program to know when it’s right or wrong. In the standard library for example, pydoc was special-cased to display the underscored attributes of named tuples (see http://hg.python.org/cpython/rev/46aaa365111f).
All this leads me to believe that code rightfully using _names should add pylint comments to disable the warnings.