What are modules really for?

N.Davis nd51 at le.ac.uk
Tue Aug 9 11:32:31 EDT 2005


I am very new to Python, but have done plenty of development in C++ and 
Java.

One thing I find weird about python is the idea of a module. Why is this 
needed when there are already the ideas of class, file, and package?

To my mind, although one CAN put many classes in a file, it is better to 
put one class per file, for readability and maintainability.

One can then create packages and libraries, using groups of files, one 
class per file.

Python seems to let you group classes together in one file and call it a 
module, but what for?

I find that this, combined with mixins, makes it difficult to find out 
where code is inherited from.

With single inheritance in C++ or Java, if you wanted to see what a 
method did and it appeared to be inherited, you would simply look in the 
base class's file, and if necessary recurse up the inheritance hierarchy 
until you found the method.

With Python an inherited method could be in one of many base classes 
and/or mixins and there seems no particular logic as to what the 
filename would be.

Am I missing something?

Any comments would be appreciated.

Thanks
Nick Davis




More information about the Python-list mailing list