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


Groups > comp.lang.python > #66644

Re: Import order question

References <53020843.5010804@shopzeus.com> <851tz16fzt.fsf@benfinney.id.au> <53025198.1060000@shopzeus.com> <mailman.7110.1392666057.18130.python-list@python.org> <c25d98d8-ed6b-492a-85e7-4a241589f2ef@googlegroups.com>
Date 2014-02-19 08:02 +1100
Subject Re: Import order question
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.7124.1392757348.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Feb 19, 2014 at 7:41 AM, Rick Johnson
<rantingrickjohnson@gmail.com> wrote:
>     # ui_main.py
>     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.

Absolutely definitely not. If you're going to import * into every
module, just write it all in a single source file. Otherwise, when
someone tries to find the source code for some particular class or
function, s/he has to go digging through all five source files - first
the utterly useless merge-point, then the four others, because there's
no way to know which one has it.

Python could make this easier for us, by retaining the origin of every
function and class. And maybe it's already there, but I don't know
about it. But even if it did exist (by the way, it would be useful for
other things than just taming a mad layout like this), it'd still be
better to keep everything combined, because the origin of a
function/class could just as easily go to the exact line as to the
file.

A module is a namespace. It should be used as such. If you want a
package, use a package. There's no point putting each class out
separate unless you really need that.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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