Relative Imports, why the hell is it so hard?

Maxim Khitrov mkhitrov at gmail.com
Mon Mar 23 12:24:41 EDT 2009


On Mon, Mar 23, 2009 at 12:19 PM, CinnamonDonkey
<CinnamonDonkey at googlemail.com> wrote:
> My applogies if this is a silly question... but what makes something a
> package? and does that mean that what I am trying to do is not
> possible ?

A package is a directory that has an __init__.py file. That file can
be empty, or contain some initialization code. In your original
example, subpack1 and subpack2 are packages. By adding an empty
__init__.py file under \App, I made App into a package, which allowed
me to execute "import App.subpack1.module1" in main.py.

See the following url for additional info:
http://docs.python.org/tutorial/modules.html

- Max



More information about the Python-list mailing list