Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #66623

Re: Import order question

From Ben Finney <ben+python@benfinney.id.au>
Subject Re: Import order question
Date 2014-02-18 06:40 +1100
References <53020843.5010804@shopzeus.com> <851tz16fzt.fsf@benfinney.id.au> <53025198.1060000@shopzeus.com>
Newsgroups comp.lang.python
Message-ID <mailman.7110.1392666057.18130.python-list@python.org> (permalink)

Show all headers | View raw


Nagy László Zsolt <gandalf@shopzeus.com> 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.

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.

> I never know when to put classes in different modules. I usually draw
> an UML diagram and group classes into packages. Wich makes sense
> because there can be sub-groups with subpackages. But I'm always
> confused with modules, I don't know why.

You can start by making one module for each of those groupings. (The
term “package” already has a specific technical meaning in Python, and
I'm not sure whether that's what you meant here.)

> Thanks for the help.

Welcome to Python!

-- 
 \      “If sharing a thing in no way diminishes it, it is not rightly |
  `\                   owned if it is not shared.” —Augustine of Hippo |
_o__)                                                                  |
Ben Finney

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Import order question Ben Finney <ben+python@benfinney.id.au> - 2014-02-18 06:40 +1100
  Re: Import order question Rick Johnson <rantingrickjohnson@gmail.com> - 2014-02-18 12:41 -0800
    Re: Import order question Chris Angelico <rosuav@gmail.com> - 2014-02-19 08:02 +1100
      Re: Import order question Rick Johnson <rantingrickjohnson@gmail.com> - 2014-02-18 13:44 -0800
        Re: Import order question Chris Angelico <rosuav@gmail.com> - 2014-02-19 08:49 +1100
          Re: Import order question Grant Edwards <invalid@invalid.invalid> - 2014-02-18 22:44 +0000
        Re: Import order question Tim Chase <python.list@tim.thechases.com> - 2014-02-18 16:17 -0600
          Re: Import order question Grant Edwards <invalid@invalid.invalid> - 2014-02-18 22:45 +0000
          Re: Import order question Rick Johnson <rantingrickjohnson@gmail.com> - 2014-02-18 14:49 -0800
        Re: Import order question Rotwang <sg552@hotmail.co.uk> - 2014-02-18 23:28 +0000
          Re: Import order question Rick Johnson <rantingrickjohnson@gmail.com> - 2014-02-18 15:41 -0800
            Re: Import order question Rotwang <sg552@hotmail.co.uk> - 2014-02-19 01:09 +0000
            Re: Import order question Steven D'Aprano <steve@pearwood.info> - 2014-02-19 07:32 +0000
          Re: Import order question MRAB <python@mrabarnett.plus.com> - 2014-02-19 00:18 +0000
        Re: Import order question Chris Angelico <rosuav@gmail.com> - 2014-02-19 12:57 +1100
        Re: Import order question Steven D'Aprano <steve@pearwood.info> - 2014-02-19 07:32 +0000
          Re: Import order question Chris Angelico <rosuav@gmail.com> - 2014-02-19 18:59 +1100
          Re: Import order question Roy Smith <roy@panix.com> - 2014-02-19 08:28 -0500

csiph-web