module confusion

Steve Holden steve at
Fri Oct 5 13:37:34 CEST 2007

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 


>                                                              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 
> Just to pick some random examples:
>>>> import ConfigParser, base64, fileinput
> <module 're' from '/usr/lib/python2.5/re.pyc'>
>>>> base64.struct
> <module 'struct' from '/usr/lib/python2.5/struct.pyc'>
>>>> base64.binascii
> <module 'binascii' from '/usr/lib/python2.5/lib-dynload/'>
>>>> fileinput.sys
> <module 'sys' (built-in)>
>>>> fileinput.os
> <module 'os' from '/usr/lib/python2.5/os.pyc'>
> It's quite common.
OK, I am sort of getting used to the idea that you guys are going to 
beat this one to death with a stick, and will still be tossing emails 
back and forth to each other while the rest of us are admiring the heat 
death of the universe.

So please try and avoid 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.

Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd 
Skype: holdenweb

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

More information about the Python-list mailing list