Opening file problem in wxWindows program

David Bolen db3l at fitlinxx.com
Thu Sep 14 15:39:47 EDT 2000


David Ishee <isheedm at yahoo.com> writes:

> I saw in the wxWindows docs to use the import * statement so I copied
> and pasted for the others. Thanks for the help.

wxPython is one of those packages that wraps the underlying wxWindows
library already established with a common naming scheme that uses a
"wx" prefix for everything.  Because of this, it's safe (well, unless
you're using a lot of objects named starting with "wx" :-)) for
inclusion with "import * from" since everything it ends up binding in
the local name space will start with "wx".  If you didn't do this,
you'd end up saying "wx.wx***" for every function, so it's more
readable as well.  Cases like this (a wrapped external library) is
often when this comes up since the wrapped language probably didn't
have the sort of modular namespace that Python does.  You find this
much less common with native Python modules, although those built to
permit this safely do exist.

But this is definitely not the common or default approach one should
take with Python modules.  Only those modules that have been designed
to help avoid collisions in your local namespace should be considered
suitable for "import * from".  

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list