Import order question

Rick Johnson rantingrickjohnson at
Tue Feb 18 21:41:20 CET 2014

On Monday, February 17, 2014 1:40:41 PM UTC-6, Ben Finney wrote:
> Nagy László Zsolt ... writes:
> > > Use modules to group your class definitions conceptually. There is
> > > no need whatever to separate every class into a different module.
> > If there is a consensus, and it is really desireable to put all these
> > related classes into the same module, then this is what I'm going to
> > do.

It is not desirable to me, and i would argue truthfully,
to many others either.

> You should use multiple modules to separate the code where it makes
> sense, along *conceptual* lines. Make separate modules that each
> represent a conceptually-separate area of functionality in your
> application, and put the classes which implement that functionality in
> that module.

Classes with an "s"? As in many classes in one source file?
Are you insane man? Why oh why would you torture yourself
and others with such advice? Are you some sort of hard disc
neat freak? Do you fear cluttering your hard-drive with too
many files will overwork it? What of yourself?

I'm continually amazed by you "Java haters" who will
willingly place burdens on yourself just to spite that "mean
old Java". Splitting code into small source files is wise,
whereas, creating single monolithic monstrosities like
Tkinter should be a sin! A sin that should be punishable by
the Exception!

As the lines of code increase, so does the complexity of
navigating and maintaining large modules. Classes should
naturally exist in their own module with the exception of
small utility or special use classes that are not exposed

Then you go and intermix the areas of "module source code"
and "module API". These are two distinct areas that need not
follow the same patterns. You can have 20 classes contained
in 20 different source files and then combine them
transparently at run-time so that as far as the client is
concerned, all the classes exist under one namespace.

    class One():pass

    class Two():pass

    class Three():pass

    class Four():pass

    from ui_mod1 import *
    from ui_mod2 import *
    from ui_mod3 import *
    from ui_mod4 import *

At least by this method i can maintain the code base without
wearing-out my scroll finger and eventually loosing my mind.
THE MORAL: With very few exceptions, please put EVERY class
in it's own module.

More information about the Python-list mailing list