There are numerous parallels between the definitions for modules and classes:
- Both modules and classes have names defined by the Python syntax rules. To help distinguish them, modules usually have a leading lowercase letter; classes usually have a leading uppercase letter.
- Module and class definitions are namespaces that contain other objects.
- A module is a Singleton object within a global namespace, sys.modules. A class definition is unique within a namespace, either the global namespace, __main__, or some local namespace. A class definition is slightly different from a module Singleton, because a class definition can be replaced. Once imported, a module can't be imported again without using special functions ...