Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Explicit or general importing of namespaces?

Thread Tools

Explicit or general importing of namespaces?

Harlin Seritt
Posts: n/a
I think the bottom line on this is using your own sense of risk/reward with
each given module imported. Some modules (Tkinter comes to mind) it makes
sense to pollute while others it doesn't.


"Peter Hansen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Peter Mayne wrote:
> > Peter Hansen wrote:
> >> and it's still a bad idea in almost all cases anyway

> >
> > 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 *

> This sort of thing seems common amongst large frameworks such
> as PyQt or wxPython. This is unfortunate, IMHO, though it isn't
> really a serious concern for most users.
> I'm grateful that the most recent versions of wxPython have
> abandoned that approach in favour of a nice clean "import wx",
> and as far as I can tell the code does not suffer as a result,
> and gains substantially in clarity. Maybe the "qt" module
> defines far fewer names than the "wx" module does, but I for
> one am glad not to have to worry that I won't accidentally
> conflict with the hundreds that are there (in wx), nor to
> worry that my code lacks in readability.
> > 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.

> If not sensible, at least fairly widely accepted, not a serious
> impediment to effective use, and definitely not without precedent.
> -Peter

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
General....very general.... no important for u forever hi Python 0 03-18-2009 08:21 AM
Explicit instantiation of STL vector demands explicit instantiation of all the templates it using internally. C++ 1 12-25-2006 03:51 PM
How to keep a module with the same name as a module it is importing from importing itself? plb Python 2 02-08-2005 03:14 PM
What's the difference betwwen explicit instantiaion and explicit specialization? Andy C++ 5 01-30-2005 11:46 PM
Is explicit template qualification required for explicit delete? J.T. Conklin C++ 1 08-11-2004 02:06 AM