'python' keyword | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

18th Jul 2018, 10:21 AM
Seb TheS
Seb TheS - avatar
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.
19th Jul 2018, 1:09 PM
Nboumakis
+ 1
Nboumakis I missed some mistakes when shared this question, now those are fixed and also fixed that someone would think I read Pydroid as book, but I use Pydroid as compiler. But the question what is that 'python' keyword
18th Jul 2018, 12:28 PM
Seb TheS
Seb TheS - avatar
+ 1
Happy to help.
20th Jul 2018, 7:07 AM
Nboumakis
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.
18th Jul 2018, 11:48 AM
Nboumakis
0
Nboumakis That cleared a lot! Thanks!
19th Jul 2018, 2:31 PM
Seb TheS
Seb TheS - avatar