What are modules really for?

Sion Arrowsmith siona at chiark.greenend.org.uk
Wed Aug 10 09:07:30 EDT 2005


infidel <saint.infidel at gmail.com> wrote:
>> [ somebody else wrote: ]
>> 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.
>Personally I find it easier to maintain a set of related classes when
>they're all in the same file.

Real world example: I have here an API I'm one of the maintainers of
which is available in C++, Java and Python versions. Part of the
nature of this beast is that it has about 20 exception classes derived
from the same base class. So that's one .py for the Python interface,
a .h and a .cxx for the C++ (there is some logic in the base class
which counter-indicates stuffing it all in one .h), and 21 .java files
(plus their corresponding .classes). Take a guess which ones[*] are
easiest to maintain. ([*] hint)

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list