Skip to content
← Back to Community
How do I provide a command line argument or parameter in Repl.it's Python?
Profile icon
yoctoritz

I have a programming assignment for my students to handle command-line arguments in Python. I have attached the part that does this. The difficulty in using Repl.it is that I don't know where to enter the command-line argument (also known as command line parameter). Normally the user would enter this on the command line of the console right after the program name, and, in PyCharm, they enter would enter it in the configuration under Parameters.

I'm sure I could have the students hard-code the contents of the argument into the program, but that would defeat the purpose of the assignment. So, how do I enter the command-line argument? Or is that even possible with Repl.it?

In the Repl.it that I attached, the program is expecting the user to use jabber.txt or special.txt as the argument because they have both of those files available to them.

P.S. The reason I want to use Repl.it for this is because my school (Tulsa Community College) has gone to online-only classes in response to COVID-19, and the computer lab is now closed. A few of my students don't have a computer that they have admin rights to, so they can't set up PyCharm IDE on it. If we can't get Repl.it to work for their assignments, those students might have to take an incomplete, but I know that most students never finish an incomplete, so their grades would convert to F's, which I really don't want to see happen.

Voters
Profile icon
mbender88
Profile icon
yoctoritz
Comments
hotnewtop
Profile icon
SixBeeps

If you hit the key combo Ctrl+Shift+S, the shell window will appear. From there, you can execute your program as if you were running it through the terminal.

Profile icon
yoctoritz

@SixBeeps Thanks so much. It took a few tries, but I discovered that the "name" of the python file is apparently always main.py, so here was the command after pressing Ctrl+Shift+S:
python main.py special.txt