Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'importing': 0.04; 'definitions': 0.07; 'definitions.': 0.07; 'executable': 0.07; 'executed': 0.07; 'table.': 0.07; 'imported': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sentence': 0.09; 'sure,': 0.09; 'terry': 0.09; 'bug': 0.10; 'def': 0.10; ':-)': 0.13; '"...': 0.16; '11:32': 0.16; 'describing': 0.16; 'enough.': 0.16; 'finney': 0.16; 'message-id:@dough.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'roy': 0.16; 'somewhere.': 0.16; 'subject:import': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'module': 0.19; 'file.': 0.20; 'supposed': 0.21; 'statement': 0.23; 'url:bugs': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; '[1]': 0.27; 'am,': 0.27; 'execution': 0.27; 'header:X-Complaints-To:1': 0.28; 'this?': 0.28; 'statements': 0.29; 'this.': 0.29; 'function': 0.30; 'url:python': 0.32; 'file': 0.32; 'anywhere': 0.33; 'says': 0.33; 'symbol': 0.33; 'to:addr :python-list': 0.33; 'tutorial': 0.33; 'ben': 0.35; 'received:org': 0.36; 'really': 0.36; 'url:org': 0.36; 'should': 0.36; 'subject:: ': 0.38; 'fact': 0.38; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'different': 0.63; 'subject:...': 0.63; 'more': 0.63; '8bit%:38': 0.65; '8bit%:40': 0.65; 'skip:\xe2 10': 0.66; 'august': 0.66; 'smith': 0.71; '"they': 0.84; 'received:fios.verizon.net': 0.84; 'subject:thought': 0.84; 'url:tutorial': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: I thought I understood how import worked... Date: Tue, 07 Aug 2012 13:15:37 -0400 References: <87txweiz7f.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1344359780 news.xs4all.nl 6962 [2001:888:2000:d::a6]:59615 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26731 On 8/7/2012 11:32 AM, Roy Smith wrote: > On Tuesday, August 7, 2012 9:55:16 AM UTC-4, Ben Finney wrote: > >> The tutorial is misleading on this. It it says plainly: >> >> A module can contain executable statements as well as function >> definitions. [=E2=80=A6] They are executed only the *first* time the >> module is imported somewhere. The last sentence should be more like "They are executed only the *first* time the module is imported anywhere with a particular name. (One should avoid importing a module under different names.) >> >> [1] In fact function definitions are also =E2=80=98statements=E2=80=99= that are >> =E2=80=98executed=E2=80=99; the execution of a module-level function e= nters the >> function name in the module=E2=80=99s global symbol table. > > I think what it's supposed to say is "... the execution of a > module-level def statement ..." right >> Care to file a documentation bug >> describing this? > > Sure, once I understand how it's really supposed to work :-) You don't need a final solution to file. Anyway, I think the change=20 above might be enough. --=20 Terry Jan Reedy