I have a directory structure like -
- D
- dir1
- filetoimport.py
- dir2
- filetoimport.py
- run.py
- dir1
Filetoimport.py code-
call_function()
do_something
return
Run.py has -
import filetoimport
filetoimport.call_function()
the dir2 is essentially a copy of dir1 with some changes but run.py is still calling filetoimport from dir1. I don't get what am I missing here?
EDIT 1- dir1 and dir2 are not packages but just plain directories.
__init__.py?__init__. pyfile in each package? Finaly you should call it from the root.from dir2 import filetoimportfrom package.module import needed_function, orimport package.module(qualified name with package name), orimport package.module as different_name(you can doason single functions with colliding names as well!)from D.dir2 import filetoimport. And you should have init file in each directory.