On my root home directory, I have the following git repositories:
/root/foo
/root/foo-lib
One python file, let's say hello.py, in /root/foo/scale/hello.py needs a file from /root/foo-lib called bar.py (/root/foo-lib/lib/bar.py)
Inside hello.py I may have:
import scale.test as test
...
And many others. However, I need to import the bar.py library into that file, which is in a separate repository. How can I accomplish that? I need something like
import foo-lib.lib.bar as bar
in my hello.py file. I'm no sure how to achieve that. Could someone give me a clue?
-
Hi, were you able to resolve this?Anshul Goyal– Anshul Goyal2015年01月26日 14:20:41 +00:00Commented Jan 26, 2015 at 14:20
1 Answer 1
You can create a file /root/__init__.py, and within /root/foo/scale/hello.py, you can use the statement
import ...foo-lib.lib.bar as bar
Another alternative is to create a symlink within your /root/foo/scale/ directory, pointing towards /root/foo-lib