Toplevel "test()" functions in standard library

Peter Schneider-Kamp peter at schneider-kamp.de
Wed Jul 19 08:00:31 EDT 2000


Rob Hooft wrote:
> 
> Wouldn't it be better to move the test() definition inside the if
> statement in these cases, to prevent name space pollution? Note that
> the routines are not called "_test()", so they will be imported by a
> "from ... import *" (There are other modules with a _test() definition
> as well).

I cannot comment on the reason for this idiom, but for your
name space pollution using "from ... import *": Don't use it.

<rant>Even in the short time I have been on the list I have seen
examples of nearly untrackable bugs because of name space
collisions when using "from ... import *".</rant>

I don't even use "from Tkinter import *" in GUI apps.
I prefer "import Tkinter; tk = Tkinter; del Tkinter",
though it would be really nice to have something like this:
"import Tkinter as tk"
Which would be short for
"tk=__import__("Tkinter",globals,locals,None)"

Peter
--
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter at schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de




More information about the Python-list mailing list