4 ms·
> I can see the value in quickly knowing if new code is mucking with private/protected properties. Would this do it? re.findall(r'(?<!self)\._\w+', source
by msellout 11y ago
> I can see the value in quickly knowing if new code is mucking with private/protected properties.
Would this do it?
re.findall(r'(?<!self)\._\w+', sourcelines)
Anytime you're using ``obj._foo`` and it's not ``self._foo`` that suggests you're mucking about with the internals of an object that the author didn't expect you to use.
- tyingq 11y agoThat would miss some things, like iteration of all properties without a direct reference, subclasses accessing _Parent__private stuff, etc. I'm not actively looking for a solution, just noting this might be more well received if you could easily turn it off and on. Edit: Again, not looking for solutions. I thought the feedback of being able to turn it on/off might be useful for the OP.
- msellout 11y agoWell, for your future reference, Pylint (https://www.pylint.org/ https://www.pylint.org/) checks for that and many other common pitfalls. I'm sure its competitors PyChecker and Pyflakes do so as well.