One class per file?
bignose+hates-spam at benfinney.id.au
Mon Sep 29 15:21:58 CEST 2008
HCB <hypercaffeinatedbiped at gmail.com> writes:
> The book "Code Complete" recommends that you put only one class in a
> source file, which seems a bit extreme for me.
For Python, that is extreme, and for most applications I've seen it
would be counterproductive. Which edition of Code Complete recommends
this, and on which page?
> Perhaps a better rule of thumb is "one idea per file." I checked the
> Python style guide and there seems to be no mention of this topic. I
> know this is an elementary question, but what is the Python way of
> doing this?
You have it right: modules are most naturally used for conceptual
grouping of objects (not just classes, but all objects) related to a
discrete area of functionality, into a discrete namespace.
\ “The WWW is exciting because Microsoft doesn't own it, and |
`\ therefore, there's a tremendous amount of innovation |
_o__) happening.” —Steve Jobs |
More information about the Python-list