Chapter 4. Choosing Good Names
Most of the standard library was built keeping usability in mind. For instance, working with built-in types is done naturally and was designed to be easy to use. Python, in this case, can be compared to the pseudocode you might think about when working on a program. Most of the code can be read out loud. For instance, this snippet should be understandable by anyone:
my_list = [] if 'd' not in my_list: my_list.append('d')
This is one of the reasons why writing Python is so easy when compared to other languages. When you are writing a program, the flow of your thoughts is quickly translated into lines of code.
This chapter focuses on the best practices for writing code that is easy to understand and use, through:
- The usage of naming conventions, described in PEP 8
- The set of naming best practices
- The short summary of popular tools that allow you to check for compliance with styling guides