I want to use git to allow me to work with several functions in a module that I am writing at the same time. I am currently using SVN with only one workspace, so I just have a workspace on PYTHONPATH. I understand that this is less than ideal, so I was wondering if anyone could suggest a more “right” way to do this.
Let me clarify a hypothetical situation: I say that I have an egg module, with submodules foo and bar. The components in the bar use the code in foo, so egg / bar / a.py can import eggs.foo.
Say the "eggs" are in the git repository. I want to try some changes in "foo", so I will copy it. The problem is that "import eggs.foo" in the eggs / bar finds the source repository in PYTHONPATH, so it ends up using the old "foo" instead of my modified one.
How to configure yourself so that each copy of the module uses its own "foo"? Thanks.
edit- Thanks for the pointer to relative imports. I read about it and I see how to apply it. One of the problems that I would encounter is that I created a rather large code base and I was not too neat, so most modules have a quick "self-test" under if __name__ == '__main__': from which I read that it does not play with relative imports:
Another solution I was able to execute google with is to intentionally manipulate sys.path, which seems to be an even worse hack. Are there any other options?
edit - Thanks for the suggestions. I initially misunderstood the git branches, since the indicated branches are exactly what I want. However, I have not heard of relative imports before, thanks for that. I learned something new and can turn on its use.
source share