Explicit or general importing of namespaces?

Peter Mayne Peter.Mayne at hp.com
Tue Mar 1 05:09:29 EST 2005


Peter Hansen wrote:
> 
> In general, unless the names being imported are *guaranteed*
> never to be rebound, it is a very bad idea to use "import *",
> and it's still a bad idea in almost all cases anyway, for
> reasons already given by others.

Since I've been playing with PyQt lately...

Is qt not one of the "almost all" cases? From the limited number of 
examples I've seen, it seems to be common to do

from qt import *

Since most of the imported names start with "Q", are called QLabel, 
QSlider, etc, and are generally recognisable in context, this would seem 
to be a reasonable case of namespace pollution.

I'm certainly not arguing with the general premise, just wondering if qt 
is one of the sensible exceptions.

PJDM



More information about the Python-list mailing list