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


Groups > comp.lang.python > #102683 > unrolled thread

A question about imports in wxpython

Started bycl@isbd.net
First post2016-02-08 15:44 +0000
Last post2016-02-08 09:25 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  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

#102683 — A question about imports in wxpython

Fromcl@isbd.net
Date2016-02-08 15:44 +0000
SubjectA question about imports in wxpython
Message-ID<pnpmoc-ved.ln1@esprimo.zbmc.eu>
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?

-- 
Chris Green
ยท

[toc] | [next] | [standalone]


#102687

FromIan Kelly <ian.g.kelly@gmail.com>
Date2016-02-08 09:25 -0700
Message-ID<mailman.108.1454948786.2317.python-list@python.org>
In reply to#102683
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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web