Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Ideone support Python command line parameters?

I'm trying to remotely guide a few people in my office toward Python, and the easiest way to do that seems to be showing them how these simple Python samples ...

http://wiki.python.org/moin/SimplePrograms

... run in a sandbox like ideone.com.

All goes well until example eight ("Command line arguments, exception handling").

I am seeing no way to send arguments to the ideone interpreter, and when I try to squeeze values through stdin, they appear to be ignored. Does anyone know how to do this? The ideone FAQ says nothing on the matter of arguments.

If not, is there another web-based Python interpreter that accepts stdin and args and might do the trick?

Thanks in advance. You guys are great.

like image 807
eternalnewb Avatar asked Feb 09 '12 17:02

eternalnewb


People also ask

How do you pass arguments to a Python file?

In Python, arguments are passed to a script from the command line using the sys package. The argv member of sys ( sys. argv ) will store all the information in the command line entry and can be accessed inside the Python script. Python's getopt module can also be used to parse named arguments.

How do I pass command line arguments in Intellij?

From the main menu, select Run | Edit Configurations or choose Edit Configurations from the run/debug configurations selector on the toolbar. In the Run/Debug Configurations dialog that opens, select a configuration where you want to pass the arguments. Type the arguments in the Program arguments field.


2 Answers

An alternative is PythonAnywhere. There's an instant demo, and you can log in to get space to store scripts, and a variety of shells.

When you're logged in, you can start a bash shell, and run Python scripts from the command line with whatever arguments you want.

like image 133
Thomas K Avatar answered Sep 23 '22 07:09

Thomas K


If you want to use ideone, you can simulate params by extending the sys.argv variable. For your example:

sys.argv.extend(['3', '4', '5'])

Just after import sys.

here's the ideone link: http://ideone.com/8pH8A

like image 24
nosklo Avatar answered Sep 24 '22 07:09

nosklo