The naming guide
A common set of naming rules can be applied on variables, methods, functions, and properties. The names of classes and modules also play an important role in namespace construction, and in turn in code readability. This mini-guide provides common patterns and antipatterns for picking their names.
Using the has or is prefix for Boolean elements
When an element holds a Boolean value, the is
and has
prefixes provide a natural way to make it more readable in its namespace:
class DB: is_connected = False has_cache = False
Using plurals for variables that are collections
When an element is holding a collection, it is a good idea to use a plural form. Some mappings can also benefit from this when they are exposed like sequences:
class DB: ...
Get Expert Python Programming - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.