View Single Post
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2021-05-29, 19:31

Quote:
Originally Posted by tomoe View Post
❤️ black & flake8 checking. Have both of those setup as pre-commit hooks on my work laptop and as part of the CI/CD.
Nice! We call flake8 (with flake8-black) from a tox env we run in CI and/or locally. We don't use commit hooks, but to protect the repo, we simply forbid anyone from committing or pushing directly to master, and all code must come through pull requests with passing flake8/black/coverage/etc. jobs before they can merge. The green checks are a beautiful thing!



I actually have my local editor set up to automatically run black every time it saves a Python file. I resisted auto-formatters at first, but getting to just turn off that part of the brain and never think about debating style choices is soooooooo good.

Quote:
Originally Posted by tomoe View Post
The logging module can be pretty handy if you want to move beyond print statements, e.g.
100%. The logging module is definitely an upgrade for generating good console output, especially for any long-running code. What's also great about using the logging module (this is probably more for turtle's education…) is that you can configure the logging module at a high level with different handlers and formatters to, for example, send some logs to files on disk and some logs to stdout, or prepend the timestamp and process ID to all messages, or only output things logged at "error" in one part of your code but output everything at "debug" in some other part of your code. Heck, some of our Python services have a logging handler that intercepts log messages and sends them across the internet into AWS CloudWatch storage! Python logging configuration is very powerful, though understanding all the options can be overwhelming at first.

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote