Maintainability (was Re: Stackless & String-processing)

Aahz Maruch aahz at netcom.com
Thu Jul 22 11:01:28 EDT 1999


In article <14230.42741.34295.650213 at 153.chicago-05-10rs.il.dial-access.att.net>,
Skip Montanaro  <skip at mojam.com> wrote:
>>>>>> "Aahz" == Aahz Maruch <aahz at netcom.com> writes:
>
> Aahz> Yup.  Today I had to lay down the law to our programming team: use of
> Aahz> the construct "from foo import *" is now expressly, explicitly, and
> Aahz> completely forbidden.  "from foo import bar" is deprecated; "from foo
> Aahz> import foo" is acceptable; and "import foo" is strongly preferred.
>
> Aahz> I'd be in favor of getting "from foo import *" entirely out of the
> Aahz> language, but I suspect it's just too convenient for short hacks.
>
>What Tim said about programmers not inventing control structures is somewhat
>different than what Aahz put his foot down about.  There's nothing wrong
>with "from foo import *" when it's used in the right context.  Some modules
>in the standard distribution were designed specifically to support this
>(types and Tkinter come to mind).  Used willy-nilly, you can get into
>trouble with it, one-man show or not.

I'm afraid I can't agree that there's *ever* a good time to use "from
foo import *" in a multi-programmer environment.  Too often, you have a
programmer new to a particular chunk of code trying to debug it; not
knowing exactly where a method/function call is coming from vastly
increases debugging time (particularly when there are hundreds of
modules and scripts).  If you want to use an unadorned class/function,
you can just take the trouble to explicitly list it as "from foo import
bar, baz".

My point was related to Tim's in that we're both talking about how
Python's strait-jacket approach is a Good Thing; I'm simply using an
example where I think Python could actually be tightened.
--
                      --- Aahz (@netcom.com)

Androgynous poly kinky vanilla queer het    <*>      http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6  (if you want to know, do some research)




More information about the Python-list mailing list