import packet.module without importing packet.__init__ ?

Gelonida N gelonida at gmail.com
Sun Sep 11 02:05:13 CEST 2011


Hi,

I am little shaky with how exactly python imports packages / modules etc.

Is it possible to import a module from a packet without importing its
__init__.py ?


Full example:
==============

# application.py ---------------------
print "starting application"
import mypacket.module1

# mypacket.__init__.py ---------------------
print "importing __init__"


# mypacket.module1.py ---------------------
print "importing module1"



The output, that I get with python 2.6 is
$ python application.py
> starting application
> importing __init__
> importing module1

Under certain circumstances I'd like to avoid the implicit import
of __init__.py

Due to other constrains of my project I am obliged to have a
non empty __init__.py







More information about the Python-list mailing list