Module and package names
The module and package names inform about the purpose of their content. The names are short, in lowercase, and without underscores:
sqlite
postgres
sha1
They are often suffixed with lib
if they are implementing a protocol:
import smtplib import urllib import telnetlib
They also need to be consistent within the namespace, so their usage is easier:
from widgets.stringwidgets import TextWidget # bad from widgets.strings import TextWidget # better
Again, always avoid using the same name as that of one of the modules from the standard library.
When a module is getting complex, and contains a lot of classes, it is good practice to create a package and split the module's elements in other modules.
The __init__
module can also be used ...
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.