how to include a file -- not import??

Matt Gushee mgushee at havenrock.com
Thu Jan 6 08:11:10 EST 2000


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.

-- 
Matt Gushee
Portland, Maine, USA
mgushee at havenrock.com
http://www.havenrock.com/



More information about the Python-list mailing list