Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102687

Re: A question about imports in wxpython

From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: A question about imports in wxpython
Date 2016-02-08 09:25 -0700
Message-ID <mailman.108.1454948786.2317.python-list@python.org> (permalink)
References <pnpmoc-ved.ln1@esprimo.zbmc.eu>

Show all headers | View raw


On Mon, Feb 8, 2016 at 8:44 AM,  <cl@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.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

A question about imports in wxpython cl@isbd.net - 2016-02-08 15:44 +0000
  Re: A question about imports in wxpython Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-08 09:25 -0700

csiph-web