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


Groups > comp.lang.python > #36798

Re: Python modules

Newsgroups comp.lang.python
Date 2013-01-14 08:27 -0800
References <kd1667$k6$1@news1.carnet.hr> <mailman.502.1358175849.2939.python-list@python.org>
Subject Re: Python modules
From Rick Johnson <rantingrickjohnson@gmail.com>
Message-ID <mailman.504.1358180885.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Monday, January 14, 2013 9:04:00 AM UTC-6, Chris Angelico wrote:
> The performance cost of reimporting a module is very low;
> in fact, trying to avoid it by adorning all your usage
> with an extra dot-level will probably cost you a lot more,
> since there'll be an extra lookup every time.

Most people "adorn" a module with an extra dot to:

    1. create a shorter name (f.e.[1] tk instead of Tkinter)
    
    2. keep their namespace clean. 

Only a fool would do "from Tkinter import *"[2]. A wise programmer, who needed to access many members of Tkinter, would do instead "import Tkinter as tk", and then prepend all members with "tk.".

[1] Abbr: (F)or (E)xample. (I feel an EnglishWart brewing on this subject!)
[2] With the exception of command line testing, learning, or playing.

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


Thread

Python modules zoom <zoom@yahoo.com> - 2013-01-14 15:54 +0100
  Re: Python modules Dan Sommers <dan@tombstonezero.net> - 2013-01-14 15:01 +0000
    Re: Python modules zoom <zoom@yahoo.com> - 2013-01-14 16:03 +0100
  Re: Python modules Chris Angelico <rosuav@gmail.com> - 2013-01-15 02:04 +1100
    Re: Python modules Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-14 08:27 -0800
    Re: Python modules Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-14 08:27 -0800
      Re: Python modules Grant Edwards <invalid@invalid.invalid> - 2013-01-14 19:48 +0000

csiph-web