A startup puzzle

Peter Hansen peter at engcorp.com
Thu Oct 2 13:42:39 EDT 2003


"Edward K. Ream" wrote:
> 
> > Okay, I won't discuss, I'll just tell you that this is a recipe for
> > giving yourself a headache.
> 
> The more I think about this remark, the more I tend to agree with you.  What
> I said about not having trouble with "from leoGlobals import *" is true, and
> yet...
> 
> The problem isn't so much the present namespace pollution, the problem is
> that the technique doesn't extend well.  There comes a point at which there
> are just too many names to keep track of.  So if I were managing a group of
> programmers (thank goodness I'm not :-) I would tend to disapprove of what I
> have done.
> 
> Still, I don't see a perfect alternative.  For sure I wouldn't like to put a
> g. in front of hundreds or thousands of function calls.  I suppose that this
> is the kind of thing one would be forced to do in slightly larger
> projects...Any other ideas?

The wxPython project recently switched from using "from wx.wxPython import *"
to a nice simple "import wx" at the top.  All calls and constants are now of
course prefixed with "wx." where before they were unadorned.

The change seems identical to what you are proposing, and we can probably
assume it was done for very good reasons.  The resulting code, after I've 
made changes to my own, already seems more readable.  I encourage you to 
make the same switch.

-Peter




More information about the Python-list mailing list