You can solve this by restructuring your project, or by using callbacks.
Restructure approach:
- consider merging the two scripts into one
- consider creating a third script, that contains everything that the other two scripts need, but doesn't require either of them - then just import the new script in both original scripts.
Callback approach:
scriptone.py
import scripttwo
def test():
print "Hello World"
scripttwo.test(test)
scripttwo.py
def test(callback):
print "Hello World"
callback()
now, scripttwo doesn't really need to see functions from scriptone - you pass the function it needs to call as an argument (the callback).
Another way to work around the circular imports, would be to use function variables, it would look something like this:
scriptone.py
import scripttwo
def test():
print "Hello World"
scripttwo.scriptone_test = test
scripttwo.test()
scripttwo.py
scriptone_test = None
def test():
print "Hello World"
scriptone_test()
This is very similar to the callback approach, except you don't really need to change function - instead you need to perform a "setup" of sorts, before you make any calls to any of the scripttwo functions.