0

I currently have a directory structure like so:

- App
-- Model
-- Controller
-- View
-- main.py

I want to import main.py into a class into a controller file for testing purposes. How can I achieve this?

  • possible duplicate of [How to do relative imports in Python?](http://stackoverflow.com/questions/72852/how-to-do-relative-imports-in-python) – FinlayL Aug 20 '14 at 12:54

1 Answers1

3

Add an empty __init__.py file in the directory App to turn that directory into a package.

Then, provided the /path/to/App is visible in the sys.path of your python environment, you should be able to:

from App import main
wim
  • 338,267
  • 99
  • 616
  • 750