0

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?

1
  • Hi, were you able to resolve this? Commented Jan 26, 2015 at 14:20

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.