In otsu.py I have:
def Hello(n):
print "Hello",n
print "abc"
exit()
In another.py
from otsu import Hello
Hello(5)
When I run python another.py, the output is abc, not Hello, 5.
What am I doing wrong?
Firstly, make sure you don't have any stale .pyc or .pyo files in the directory. Or if you're using Python 3 then remove the __pycache__ directory just to be sure. This is likely the problem.
In another.py, running from otsu import Hello should print abc. Then running Hello(5) will produce Hello 5. So your output will look like:
abc
Hello 5
I just ran this to confirm and it worked as expected.
abcandHello, 5. Are you sure you're getting the right import?otsu.pycorotsu.pyofile in the directory with old code in itfrom otsu import *exit()after, but it turns out that was causing the problem. I didn't know that it would exit from the main program as well