The recommended way to return a value from one python "script" to another is to import the script as a Python module and directly call the functions:
import another_module value = another_module.get_value(34)
where another_module.py :
#!/usr/bin/env python def get_value(*args): return "Hello World " + ":".join(map(str, args)) def main(argv): print(get_value(*argv[1:])) if __name__ == "__main__": import sys main(sys.argv)
You can import another_module and run it as a script from the command line. If you do not need to run it as a command line script, you can remove the main() function and if __name__ == "__main__" .
See also Call python script with input using python script with subprocess .
source share