from import and __init__.py

egbert egbertum at xs4all.nl
Thu Mar 25 18:28:48 EDT 2010


On Thu, Mar 25, 2010 at 12:43:13PM -0400, Terry Reedy wrote:
> On 3/25/2010 6:16 AM, egbert wrote:
> >When I do 'from some_package import some_module'
> >the __init__.py of some_package will be run.
> >However, there will not be anything like a  package-module,
> >and the effects of __init__.py seem all to be lost. Is that true ?
> 
> No. If you do
> 
> from sys import modules
> print(modules.keys())
> 
> you will see both some_package and some_package.some_module among
> the entries. 
Yes, you are right. And I can reach everything with
modules['some_package']
or variants thereof.
Thanks,
egbert

-- 
Egbert Bouwman - Keizersgracht 197 II - 1016 DS  Amsterdam - 020 6257991
========================================================================



More information about the Python-list mailing list