Created
August 2, 2019 05:24
-
-
Save NotZombieFood/9f0b07861ef071c1db81aa7182e5dd45 to your computer and use it in GitHub Desktop.
Python Script calls another script with arguments (py2 and py3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Master | |
import sys | |
backup_argv = sys.argv | |
sys.argv = ['slave.py','NotZombieFood'] | |
if sys.version_info >= (3, 0): | |
exec(open("slave.py").read()) | |
else: | |
execfile('slave.py') | |
sys.argv = backup_argv | |
# Slave | |
import sys | |
print("Hi %s"%(sys.argv[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment