Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Mark Lawrence Newsgroups: comp.lang.python Subject: Re: importing Date: Mon, 7 Mar 2016 16:28:34 +0000 Lines: 34 Message-ID: References: <56DDA44B.7040405@vanderhoff.org> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de X9jZV3DFj/pDVjjqrivi7AoDxst5GprdxO0CHj63yizg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; 'prefix': 0.07; 'imports': 0.09; 'prefixed': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '"*"': 0.16; 'bryan': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'tk()': 0.16; 'wrote:': 0.16; 'attribute': 0.18; 'typing': 0.18; 'language': 0.19; 'correctly.': 0.22; 'lawrence': 0.22; 'space.': 0.22; 'tkinter': 0.22; 'errors': 0.23; 'import': 0.24; 'header:In- Reply-To:1': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'van': 0.26; 'errors.': 0.27; "skip:' 10": 0.28; 'implied': 0.29; 'loads': 0.29; 'somebody': 0.30; 'language.': 0.32; 'add': 0.34; 'but': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'thought': 0.37; 'names': 0.38; 'to:addr:python.org': 0.40; 'mark': 0.40; 'still': 0.40; 'space': 0.40; 'some': 0.40; 'skip:u 10': 0.61; 'charset:windows-1252': 0.62; 'our': 0.64; 'definitive': 0.84; 'pythonistas,': 0.84; 'not:': 0.93 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 80.234.129.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: <56DDA44B.7040405@vanderhoff.org> 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:104224 On 07/03/2016 15:54, Tony van der Hoff wrote: > 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? > As a slight aside, and as you've all ready had answers, you might like to read the Bryan Oakley response to this http://stackoverflow.com/questions/17466561/best-way-to-structure-a-tkinter-application -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence