What is the best way to call a script from another script?
The usual way to do this is something like the following.
def some_func(): print 'in test 1, unproductive'if __name__ == '__main__': # test1.py executed as script # do something some_func()
import test1def service_func(): print 'service func'if __name__ == '__main__': # service.py executed as script # do something service_func() test1.some_func()
This is possible in Python 2 using
See the documentation for the handling of namespaces, if important in your case.
In Python 3, this is possible using (thanks to @fantastory)
However, you should consider using a different approach; your idea (from what I can see) doesn't look very clean.