Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Tony van der Hoff Newsgroups: comp.lang.python Subject: importing Date: Mon, 7 Mar 2016 15:54:51 +0000 Lines: 25 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de rPvlyf9JE3GsPKWJ9dwEAg6Y2JlC0O7uhpR/JmSawgUA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.031 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'prefix': 0.07; 'imports': 0.09; 'prefixed': 0.09; '"*"': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'tk()': 0.16; 'attribute': 0.18; 'typing': 0.18; 'correctly.': 0.22; 'space.': 0.22; 'tkinter': 0.22; 'errors': 0.23; 'import': 0.24; 'module': 0.25; 'header :User-Agent:1': 0.26; 'van': 0.26; 'errors.': 0.27; "skip:' 10": 0.28; 'implied': 0.29; 'loads': 0.29; 'somebody': 0.30; 'to:name :python-list': 0.30; 'add': 0.34; 'but': 0.36; 'to:addr:python- list': 0.36; 'thought': 0.37; 'received:localdomain': 0.38; 'names': 0.38; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'space': 0.40; 'some': 0.40; 'skip:u 10': 0.61; 'definitive': 0.84; 'from:addr:tony': 0.84; 'received:192.168.1.7': 0.91; 'not:': 0.93 X-Virus-Scanned: Debian amavisd-new at mail.vanderhoff.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.5.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104216 I thought I understood this, but apparently not: Under py3: 1. "import tkinter" imports the whole module into the name space. Any access to names therein must be prefixed with the module name. ie top = tkinter.Tk() But tkinter.messagebox.showwarning() errors with "module has no attribute 'messagebox'" 2. "from tkinter import *" loads the name space from the module into the program name space. No need to prefix the module name onto the attribute name. Pollutes the name space, but makes typing easier. ie top = Tk() But messagebox.showwarning() still errors. 3. in either of the above cases, if I add "from tkinter import messagebox, the attribute resolves correctly. I imagined that the "*" form implied "load the lot". Evidently, my understanding is lacking. Will somebody please put me straight, or give me a reference to some definitive documentation? -- Tony van der Hoff | mailto:tony@vanderhoff.org Buckinghamshire, England |