Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion I thought I understood how import worked...

Received: by 10.180.82.226 with SMTP id l2mr1873275wiy.1.1344359784953;
        Tue, 07 Aug 2012 10:16:24 -0700 (PDT)
Path: n2ni12917726win.0!nntp.google.com!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path: <python-python-l...@m.gmane.org>
X-Original-To: python-l...@python.org
Delivered-To: python-l...@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-l...@python.org
From: Terry Reedy <tjre...@udel.edu>
Subject: Re: I thought I understood how import worked...
Date: Tue, 07 Aug 2012 13:15:37 -0400
References: <roy-B56619.09182407082...@news.panix.com>
	<87txweiz7f....@benfinney.id.au>
	<be5f6e25-5d7c-4e10-baa3-9aef422812a1@googlegroups.com>
Mime-Version: 1.0
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: <be5f6e25-5d7c-4e10-baa3-9aef422812a1@googlegroups.com>
X-BeenThere: python-l...@python.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: General discussion list for the Python programming language
	<python-list.python.org>
List-Unsubscribe: <http://mail.python.org/mailman/options/python-list>,
	<mailto:python-list-requ...@python.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/python-list>
List-Post: <mailto:python-l...@python.org>
List-Help: <mailto:python-list-requ...@python.org?subject=help>
List-Subscribe: <http://mail.python.org/mailman/listinfo/python-list>,
	<mailto:python-list-requ...@python.org?subject=subscribe>
Newsgroups: comp.lang.python
Message-ID: <mailman.3065.1344359780.4697.python-l...@python.org>
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: ab...@xs4all.nl
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

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.)

>> <URL:http://docs.python.org/tutorial/modules.html>

>> [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 <URL:http://bugs.python.org/>
>> 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