Maintainability (was Re: Stackless & String-processing)
Tim Peters
tim_one at email.msn.com
Thu Jul 22 23:08:13 EDT 1999
[Aahz Maruch, hijacks a thread & holds it hostage to "import *"]
[Skip Montanaro, regurgitates the company line -- as if that ever stopped a
terrorist]
> ...
> 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).
[Aahz counterstrikes]
> I'm afraid I can't agree that there's *ever* a good time to use "from
> foo import *" in a multi-programmer environment. [followed by the usual
> good reasons]
Political power flows from the barrel of a gun; a language flowers on the
rotting corpse of its creator. Come the revolution, use of "from foo import
*" will be punishable by exile to Perland! For that matter, so will use of
the wretched "foo" <wink>.
It's still a valuable feature of the language, though, and the Official
History here is a tad revisionist. This business about modules being
designed specifically for use with * is a latter-day invention that popped
up around the time Tkinter.py appeared; in the beginning, "import *" served
its One True Purpose: to save a pile of tedious typing in interactive mode!
Try crunching some numbers interactively with and without "from math import
*", and the intended use of this construct shines.
The other <ahem> One True Purpose was to save a pile of tedious typing when
whipping up a throwaway prototype as quickly as possible.
Their may have been another, but all Sole True "*" Purposes are
characterized by ephemerality and solitude. Anyone using "import *" in
public, or over extended periods of time, may as well just admit that they
didn't even bother to ask the name of the last cheap hooker they paid for a
5-minute fling.
explicit-import-is-the-condom-of-responsible-programming-ly y'rs - tim
More information about the Python-list
mailing list