Revision 04e5d5da-c1a9-4a5c-93ec-b5c8e683d5cb - Stack Overflow

Normally when you are developing a single application your directory structure will be similar to

 src/
 |-myapp/
 |-pkg_a/
 |-__init__.py
 |-foo.py
 |-pkg_b/
 |-__init__.py
 |-bar.py
 |-myapp.py

This lets your whole project be reused as a package by others. In `myapp.py` you will typically have a short `main` function.

You can import other modules of your application easily. For example, in `pkg_b/bar.py` you might have

 import myapp.pkg_a.foo

I think it's the preferred way of organising your imports.

You can do relative imports if you really want, they are described in [PEP-328](http://www.python.org/dev/peps/pep-0328/#rationale-for-relative-imports).

Of course, if one of your modules needs a module from _another_ application it's a completely different story, since this application is an external dependency and you'll have to handle it.

AltStyle によって変換されたページ (->オリジナル) /