using import * with GUIs?

Alexandre Fayolle alf at merlin.fayauffre.org
Wed May 31 15:49:01 EDT 2006


Le 31-05-2006, John <johnjsal at NOSPAMgmail.com> nous disait:
> Hi all. Quick question (but aren't they all?) :)
>
> Do you think it's a good idea to use the 'from <name> import *' 
> statement when using a GUI module? It seems on wxPython's site, they 
> recommend using import wx nowadays, but I wonder if that advice is 
> followed. Also, I'm still reading some Tkinter docs that seem to use 
> 'from Tkinter import *' a lot.
>
> I understand the danger of doing this, but is it safer in these cases, 
> given the more specific names that GUI frameworks tend to use 
> (sometimes!)? Or should you still qualify all your calls with the module?


Don't overlook the "import module as shortname" construct, which is a
real lifesaver for large modules when you'd rather avoid importing * 

Common idiom when using Numeric/numarray/numpy is 

import Numeric as N

Importing Tkinter as tk is imo worth it. 

-- 
Alexandre Fayolle                              LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
Python et calcul scientifique:           http://www.logilab.fr/science



More information about the Python-list mailing list