I have a method/function in a file in repo A, and I'm trying to import it in a file in repo B. So at the top of the file in repo B, I have:
from repo_A.folder.folder.File_name import Method
And then I call the method. Will this work, or is there a better way to get it to work?
Python imports care about your directory structure. As long as the file is found in the given reference, the import will work.
The recommended approach is to keep your repo (or repos structure) aligned with the directory structure you need, so you can just clone/checkout once and build your project on any machine, including other developers' machines and CI machines.
If your repo_A is depended on repo_B, consider one of the following options:
1. Merge the repos into one.
2. Use git sub-module or sub-tree.
3. Include repo_B's artifact as a dependency in repo_A - download the binary from artifactory or other binary server. In this option the `import` will be a bit different.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.