using import * with GUIs?
mwilson-to at sympatico.ca
Wed May 31 22:57:47 CEST 2006
John Salerno wrote:
> 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?
More specific? I dunno, I have trouble thinking of that
huge multitude of names in wx as specific. Who knows what
in all that might collide with names you devise?
My formative experience came when I was looking at Python
Imaging Library Demo code. Somebody did a simple call to
open and got returned an entire Jpeg image object. I knew
that open was destined to take arguments other than simple
file paths, and return things other than simple files, but
it seemed awfully soon. Then I got suspicious, looked at
the top of the code, and saw "from Image import *"
So a word, too, to people writing demo programs. Writing
"from mycode import *" obscures which code is actually yours
in the code following. Kind of defeats the purpose.
More information about the Python-list