how to include a file -- not import??

Greg McFarlane gregm at iname.com
Thu Jan 6 08:52:30 EST 2000


On 6 Jan, Matt Gushee wrote:
> bitbucket at isomedia.com (Eugene Goodrich) writes:
> 
> > On Wed, 5 Jan 2000 23:52:46 -0500, "Darrell" <news at dorb.com> wrote:
> > 
> > >from filename import *
> > >
> > >Doesn't create another namespace. Avoid this in most cases.
> > >
> > 
> > What are the implications of your statement for Tkinter?  Is that one
> > of the exceptions?
> 
> Some packages, including Tkinter, are designed to be 'safe' to use
> with 'from filename import *'. All that really means is that they are
> careful not to export any unnecessary names, and that the names they
> do export are unlikely to conflict with other commonly-used names.
> 
> E.g., when you do
> 
> from Tkinter import *
> 
> you have class names like Frame and Canvas in the global namespace --
> which are unlikely to be found except in another GUI module.
> 
> However, I've seen code that does
> 
> import Tkinter
> 
> and qualifies all the names. Guess it depends what you're doing.

Tkinter is not "careful" enough, IMHO.  It exports, inter alia, the
following names:

    At E EW N NE NO NS NW ON S SE SW Tk W Wm X Y
    ALL END OFF SEL TOP YES
    BOTH CHAR FLAT Grid LEFT Menu Misc NONE NSEW Pack TRUE Text WORD

I'm not sure how you can say that "X" and "Y" are not "commonly-used
names".

-- 
Greg McFarlane     INMS Telstra Australia     gregm at iname.com




More information about the Python-list mailing list