Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26731

Re: I thought I understood how import worked...

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 <python-python-list@m.gmane.org>
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 <tjreedy@udel.edu>
Subject Re: I thought I understood how import worked...
Date Tue, 07 Aug 2012 13:15:37 -0400
References <roy-B56619.09182407082012@news.panix.com> <87txweiz7f.fsf@benfinney.id.au> <be5f6e25-5d7c-4e10-baa3-9aef422812a1@googlegroups.com>
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 <be5f6e25-5d7c-4e10-baa3-9aef422812a1@googlegroups.com>
X-BeenThere python-list@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-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3065.1344359780.4697.python-list@python.org> (permalink)
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

Show key headers only | View raw


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. […] 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 ‘statements’ that are
>> ‘executed’; the execution of a module-level function enters the
>> function name in the module’s 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 
above might be enough.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

I thought I understood how import worked... Roy Smith <roy@panix.com> - 2012-08-07 09:18 -0400
  Re: I thought I understood how import worked... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 13:52 +0000
    Re: I thought I understood how import worked... Roy Smith <roy@panix.com> - 2012-08-07 08:25 -0700
      Re: I thought I understood how import worked... Paul Rubin <no.email@nospam.invalid> - 2012-08-07 08:53 -0700
      Re: I thought I understood how import worked... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 17:54 +0000
    Re: I thought I understood how import worked... Cameron Simpson <cs@zip.com.au> - 2012-08-08 08:47 +1000
      Re: I thought I understood how import worked... Roy Smith <roy@panix.com> - 2012-08-07 19:05 -0400
      Re: I thought I understood how import worked... Ben Finney <ben+python@benfinney.id.au> - 2012-08-08 14:14 +1000
        Re: I thought I understood how import worked... Laszlo Nagy <gandalf@shopzeus.com> - 2012-08-08 08:40 +0200
        Re: I thought I understood how import worked... Roy Smith <roy@panix.com> - 2012-08-08 09:12 -0400
        Re: I thought I understood how import worked... Cameron Simpson <cs@zip.com.au> - 2012-08-09 15:52 +1000
  Re: I thought I understood how import worked... Ben Finney <ben+python@benfinney.id.au> - 2012-08-07 23:55 +1000
    Re: I thought I understood how import worked... Laszlo Nagy <gandalf@shopzeus.com> - 2012-08-07 16:14 +0200
    Re: I thought I understood how import worked... Roy Smith <roy@panix.com> - 2012-08-07 08:32 -0700
      Re: I thought I understood how import worked... Terry Reedy <tjreedy@udel.edu> - 2012-08-07 13:15 -0400
  Re: I thought I understood how import worked... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-07 15:10 +0100
  Re: I thought I understood how import worked... Terry Reedy <tjreedy@udel.edu> - 2012-08-07 12:49 -0400
  Re: I thought I understood how import worked... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-07 18:44 +0100
  Re: I thought I understood how import worked... Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-08-08 10:47 +0200

csiph-web