Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #13093

import packet.module without importing packet.__init__ ?

From Gelonida N <gelonida@gmail.com>
Subject import packet.module without importing packet.__init__ ?
Date 2011-09-11 02:05 +0200
Newsgroups comp.lang.python
Message-ID <mailman.958.1315699526.27778.python-list@python.org> (permalink)

Show all headers | View raw


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



Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

import packet.module without importing packet.__init__ ? Gelonida N <gelonida@gmail.com> - 2011-09-11 02:05 +0200
  Re: import packet.module without importing packet.__init__ ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-11 10:56 +1000
    Re: import packet.module without importing packet.__init__ ? Gelonida N <gelonida@gmail.com> - 2011-09-11 05:39 +0200
      Re: import packet.module without importing packet.__init__ ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-11 14:51 +1000
        Re: import packet.module without importing packet.__init__ ? Gelonida N <gelonida@gmail.com> - 2011-09-11 16:17 +0200

csiph-web