-3

I have a file in the directory

app
   a
     Ulil.py
   b
     main.py

I want to import Ulil.py (at app\a) into main.py (at app\b).

How do i go about doing this. I need to move the file around as well so I don't want to put the entire path. I just to be in app\b and access only app\a. Folder name stays the same.

Jj Carl
  • 21
  • 6
  • 1
    Possible duplicate of [python: how to import the class within the same directory or sub directory](http://stackoverflow.com/questions/4142151/python-how-to-import-the-class-within-the-same-directory-or-sub-directory) – AMACB Jan 19 '16 at 23:07
  • You should be good like this `from a.Ulil import *` – gerosalesc Jan 19 '16 at 23:07

2 Answers2

0

First, create an empty file called __init__.py in a

Second, in main.py in b import it using

import sys 
sys.path.insert( 0, '../' )
from a.Util import *
fahad daniyal
  • 269
  • 4
  • 14
0

You can add the directory to sys.path:

import sys
sys.path.insert( 0, '../a' )
import Util