namespace confusion

Jeff Shannon jeff at ccvcorp.com
Fri Aug 10 19:17:43 CEST 2001


Mark Robinson wrote:

> .... Nevertheless, swapping
>
> import
>
> for my
>
> from 'whatever' import *
>
> solves my problem. I was just being lazy and trying to avoid typing the
> module names each time I called one of their functions

You were being seduced by the Dark Side.  :)  Seriously, 'from module import *'
is a *very* dangerous construct, fraught with all manner of ugliness and
complexity.  There are very few cases where that complexity is justified by the
saved typing.  The *only* place where I'd consider using that construct is with
modules which were specifically designed with that usage in mind--Tkinter,
wxPython, etc.  If you really need to save on typing, you can also 'import
somelongmodulename as mod'  (at least in Python 2.x).

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list