module confusion

Steve Holden steve at holdenweb.com
Fri Oct 5 12:03:08 EDT 2007


Steven D'Aprano wrote:
> On Fri, 05 Oct 2007 07:37:34 -0400, Steve Holden wrote:
> 
>> Steven D'Aprano wrote:
>>> On Fri, 05 Oct 2007 00:12:33 -0500, Robert Kern wrote:
>>>
>>>> This is somewhat odd, because most modules aren't exposed that way.
>>>> They are either in their own file and accessed by importing them
>>>> directly, or they are inside a package.
>>> Any time you say:
>>>
>>> import parrot
>>>
>>>
>>> in one of your modules, you export parrot to anything that
>> subsequently
> 
> Well obviously you have to write the module before people import it. I 
> didn't really think "you must obey the laws of time and space" needed to 
> be explained.
> 
But a module needn't be fully executed before it's imported.
> 
>>> imports your
>>> module. (Unless you take specific steps to prevent it, for instance
>>> with del parrot.)
>> or the creation of an __all__ containing an exclusive list of names for
>> export.
> 
> No.
> 
> __all__ only effects names imported with "from module import *", it has 
> no effect on "import module".
> 
> What was that again about avoiding "writing anything that will be 
> misconstrued by newless cloobs unfortunate enough to reach this thread as 
> a result of a search for meaningful information on Python imports"?
> 
> 
> 
Well, precisely.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline so I couldn't cat it




More information about the Python-list mailing list