2 ms·
Meta: Looking at the code at [0], all of the code is at the root level. Please, don't do that. It makes it quite hard to do static analysis on the code (i.e. py
by falcolas 11y ago
Meta: Looking at the code at [0], all of the code is at the root level. Please, don't do that. It makes it quite hard to do static analysis on the code (i.e. pylint), since merely importing the code to do the code tree walk will execute the code logic. Ditto generating documentation from the code.
It can create a fair bit of boilerplate (relative to your average Python boilerplate), but the `if name == "__main__":` guard keeps this under control.
[0] https://github.com/edmund-huber/sssgen/blob/master/bin/sssgen https://github.com/edmund-huber/sssgen/blob/master/bin/sssge...
- qihqi 11y agoExactly this. This is not what "200-lines of simple Python" should look like.
- icebraining 11y agoPylint doesn't actually import the code, just parses and processes the resulting AST, which is in my opinion how it should be done. The guard is useful if your code is already composed of multiple functions/classes, which could be called from outside without running the full logic, but in this case I'm not sure it applies.
- falcolas 11y agoFair enough, pylint and pep8 do not. Pychecker, pydoc, doctest, unittest... many other tools which are part of the typical Python development flow do.