from import and

Terry Reedy tjreedy at
Thu Mar 25 17:43:13 CET 2010

On 3/25/2010 6:16 AM, egbert wrote:
> When I do 'from some_package import some_module'
> the of some_package will be run.
> However, there will not be anything like a  package-module,
> and the effects of seem all to be lost. Is that true ?

No. If you do

from sys import modules

you will see both some_package and some_package.some_module among the 
entries. The first is the result of executing some_package/ 
As usual, that code will *not* be re-exectured on subsequent imports 
involving some_package.

 > Or can I still do something useful with ?
 > e

Some packages put something like 'from _default_stuff import *' in with the intention that the package by used as

import package

perhaps [optionally] followed by

import package.specialized_stuff

Terry Jan Reedy

More information about the Python-list mailing list