I am newbie in python programming and need your help. I am running a python script using exec(open("./path to script/script.py").read()). If I try to pass a argument then I always get the error the file doesnt exists, somehow the interpreter assumes that the string passed is the file name which is obviously not correct.
>>> exec(open("./path to script/script.py" "hello").read())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: './path to script/script.pyhello'
Anybody has any tip on how to resolve this.
Thanks for your help.
execfunction is for running python code represented as a string not a file. With exec you can "pass" parameters to you code withglobalsandlocalsbut it is not command line arguments. I suggest you to try subprocess. Also check out this question: stackoverflow.com/questions/7974849/…