Class names
The name of a class has to be concise, precise, so that it is sufficient to understand from it what the class does. A common practice is to use a suffix that informs about its type or nature, for example:
- SQLEngine
- MimeTypes
- StringWidget
- TestCase
For base or abstract classes, a Base or Abstract prefix can be used as follows:
- BaseCookie
- AbstractFormatter
The most important thing is to be consistent with the class attributes. For example, try to avoid redundancy between the class and its attributes' names:
>>> SMTP.smtp_send() # redundant information in the namespace >>> SMTP.send() # more readable and mnemonic
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.