+ 3
'python' keyword
There was an example about creating a file called script2.py: import sys def main(): print("this is our second test script file") print(sys.argv) main() I successfully writted that to a file called script2.py next book told to call it as: python script2.py arg1 arg2 3 to result: this is our second test script file ['script2.py', 'arg1', 'arg2', '3'] but for me that results in errors, I have imported contents of other files with import statement and I know that they have to be in the same directory, but what is the 'python' keyword, I didn't find it from help('keywords') I am using pydroid as compiler and reading The Quick Python Book
5 Answers
+ 2
As I wrote 'python' is not a python keyword. It is a system command. It tells the system to run the script as a python program.
+ 1
Happy to help.
0
In line 3 you have opened the bracket and the quotation mark. At the end of it you haven't closed them. This will result in syntax errors. Add a " and a ) at the end of line three to correct it.
Your code should be:
import sys
def main():
print("This is our second test script file")
print(sys.argv)
main()
However, are you sure that the book is about PyDroid? It looks more like terminal where the keyword python means that the first argument (here script2.py) should be executed via the python language.
0
Nboumakis
That cleared a lot!
Thanks!