How to structure packages

Chris Angelico rosuav at gmail.com
Thu Sep 8 04:39:16 CEST 2011


On Thu, Sep 8, 2011 at 10:29 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Peter Otten wrote:
>
>> Classes and functions are grouped into
>> submodules by their functionality rather than employing Java's mechanical
>> one-class-per-file pattern.
>
> Surely it's an anti-pattern?

I don't think that's true; Java merely enforces one _public_ class per
source file. A file can have non-public classes, although one .class
file has only one class in it (so javac will sometimes make multiple
object files from one source file). I'm not wholly sure of the
significance of public classes, though, and whether or not it's
possible to do your logical grouping and just let them be non-public.

BTW, I am not a Java fan, and I don't have any defense prepared. I
haven't actually written any serious Java code for a number of years.
Used to use it back when IBM reckoned that Java would be the big thing
that sells OS/2.

ChrisA



More information about the Python-list mailing list