- Daniel Arbuckle's Mastering Python
- Daniel Arbuckle
- 206字
- 2021-07-02 21:09:40
Basic Best Practices
In the previous chapter, we saw how to put together a Python package of code and data. In this chapter, we're going to look at some rather simple things we can do that will make our lives as Python programmers simpler overall. We'll switch gears and look at version control, which will help us to collaborate with other programmers and serve as an undo buffer for the whole lifetime of a project. We're going to look at Python's built-in virtual environment tool, venv, which allows us to keep our programs and dependencies separate from each other and the software installed on our overall system.
You'll learn how to structure our docstrings for maximum utility, how to add Rich Text formatting to them, and how to export them into hyperlinked HTML documentation for viewing in a web browser. You'll also see one more cool advantage we can get from docstrings by actually executing the examples we include in our documentation and making sure they agree with what the code actually does.
In this chapter, we'll cover the following topics:
- PEP 8 and writing readable code
- Using version control
- Using venv to create a stable and isolated work area
- Getting the most out of docstrings