A question about imports in wxpython
ian.g.kelly at gmail.com
Mon Feb 8 11:25:38 EST 2016
On Mon, Feb 8, 2016 at 8:44 AM, <cl at isbd.net> wrote:
> I'm playing with some code that uses the wxpython grid. *Every*
> example I have seen starts with the imports:-
> import wx
> import wx.grid as Gridlib
> As Gridlib is exactly the same number of characters as wx.grid I
> really don't see the point. Am I missing something?
You're not missing anything. I've actually never seen that before (or
at least never noticed). The first hit when searching "import wx.grid"
is http://wxpython.org/Phoenix/docs/html/grid_overview.html which
doesn't use the "as" (but I see some hits farther down that do).
Probably the author of that code was just trying to save a dict lookup
every time "wx.grid" is referenced (which has to look up "wx" in the
globals and then "grid" as an attribute). Seems like an unnecessary
micro-optimization to me.
More information about the Python-list