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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With