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 17:30:52 +0000 Lines: 29 Message-ID: References: <56DDA44B.7040405@vanderhoff.org> <56DDB91D.3020006@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 qE4rhmzEokq+CLJRKzLmKgc3vplb5N8ls2MumdWVevhQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'replied': 0.09; 'package,': 0.13; '__init__.py': 0.16; 'help;': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'url:html)': 0.16; 'wrote:': 0.16; 'language': 0.19; 'lawrence': 0.22; 'tkinter': 0.22; 'cheers,': 0.22; 'import': 0.24; 'header :In-Reply-To:1': 0.24; 'sort': 0.25; 'module': 0.25; 'header:User- Agent:1': 0.26; "doesn't": 0.26; 'header:X-Complaints-To:1': 0.26; 'van': 0.26; 'chris': 0.26; 'module.': 0.27; 'work.': 0.30; 'certainly': 0.30; 'e.g.': 0.30; 'guess': 0.31; 'supposed': 0.31; 'language.': 0.32; 'url:python': 0.33; 'directory,': 0.33; 'case,': 0.34; 'recommended': 0.34; 'file': 0.34; 'something': 0.35; 'should': 0.36; 'there': 0.36; 'url:org': 0.36; 'depends': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'received:org': 0.37; 'to:addr:python.org': 0.40; 'mark': 0.40; 'url:3': 0.60; 'charset:windows-1252': 0.62; 'more': 0.63; 'our': 0.64; 'detail.': 0.66; 'pythonistas,': 0.84; 'url:tkinter': 0.84 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: <56DDB91D.3020006@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:104233 On 07/03/2016 17:23, Tony van der Hoff wrote: > Thanks to all who replied to my cry for help; I understand it better > now. But: > > On 07/03/16 16:08, Chris Angelico wrote: >> >> The documentation should tell you what you need to import to make >> something work. In this case, I would guess that "import >> tkinter.messagebox" or "from tkinter import messagebox" would be the >> recommended way to use this module. > > Well, I found the tkinter documentation to be sparse in the extreme > (https://docs.python.org/release/3.1.3/library/tkinter.html), and it > certainly doesn't go into that sort of detail. > > However, more generally, how am I supposed to know that a module is part > of a package, and needs a "magic" stanza to get a module loaded? > > Cheers, It all depends on whether or not there is an __init__.py file in the directory, see e.g. http://pythoncentral.io/how-to-create-a-python-package/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence