Documentation for importing modules / pythonpath?
staschuk at telusplanet.net
Sat Feb 22 21:44:22 CET 2003
Quoth Johannes Eble:
> On Fri, 21 Feb 2003 06:37:59 -0700, Steven Taschuk
> <staschuk at telusplanet.net> wrote:
> >Why do you prefer having one class in one file?
> As far as I remenber, it is not only the Java way, but also the Eiffel
> way to have one file per class. [...]
I defer to your knowledge of Eiffel; I know nothing of it. I
didn't mean to imply (though I think I did) that Java's way was
something peculiar to Java and without precedent.
> [...] I prefer it because the class
> structure, not the file structure, should influence the logical
> structure of the program. You get this effect if you say 'One file is
> one class, end of the story' . [...]
There might be something different in the way we think about this
subject -- I'm not even sure what you're saying here.
To me, the dominant consideration in file organization is being
able to find the source code for a given entity. This is equally
easy in Java and Python: in Java, spam.eggs.ni is in
spam/eggs/ni.java; in Python, it's in spam/eggs.py. Both schemes
are simple and systematic. As you say, it's just a matter of
getting used to the scheme of the language at hand.
(Incidentally, this gives another way of showing that class-per-
file is not how Python is intended to work: if class ni is all
alone in spam/eggs/ni.py, its name is spam.eggs.ni.ni.)
That is, file organization is directly related to entity naming in
both languages; this is a win.
Entity naming, in turn, is influenced by logical structure,
depending on exactly what you mean by "logical structure".
(Normally names shouldn't encode class inheritance, for example,
but should reflect some conceptual model of the software's parts.)
Nowhere in this do I see file structure influencing logical
structure. Quite the reverse, actually.
Steven Taschuk o- @
staschuk at telusplanet.net 7O )
More information about the Python-list