Reputation: 187
I have the following directory/file layout for some code in python.
- top_directory
-fileA.py
- sub_directory
- __init__.py (do i place it here?)
- sub_sub_directory
-fileB.py (testFunc inside this file)
From inside the fileA.py
i would like to access a function called testFunc
inside fileB.py
. I read a couple other question that talk about how to do it if its one subdirectory deep but this is two. Which subdirectory should i place the init.py file in? And what should the import statement look like of the file?
Upvotes: 0
Views: 115
Reputation: 31
You can just put your fileB.py where indicated and import it with
import sub_directory.sub_directory.fileB as fileB
Upvotes: 1