Does Ideone support Python command line options?

I am trying to remotely direct several people in my office to Python, and the easiest way to do this seems to show them how these simple Python samples ...

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

... run in the sandbox, for example ideone.com .

Everything goes well until the eighth example ("Command Line Arguments, Exception Handling").

I do not see the possibility of sending arguments to the ideone interpreter, and when I try to compress the values ​​via stdin, they seem to be ignored. Does anyone know how to do this? Ideone faqs say nothing about arguments.

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

Thanks in advance. You guys are wonderful.

+4
source share
4 answers

An alternative is PythonAnywhere . There is an instant demonstration , and you can log in to get a place to store scripts and various shells.

When you are logged in, you can run the bash shell and run Python scripts from the command line with any arguments you want.

+3
source

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

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

Immediately after import sys .

here is the ideone link: http://ideone.com/8pH8A

+2
source

ideone does not seem to support command line arguments. However, it does support stdin . Under the text area of ​​the source code there is a link (starting with this entry) that reads

Click here to enter an input (stdin) or additional note

You can enter any text input here, and you can easily read it using raw_input() or just input() if you use Python3.

0
source

You can use Ideone in Bash mode to run Python with arguments. Since it does not allow you to save files, you can use the Bash heredoc function to provide a Python script:

An example :

 python - 1 2 3 <<EOF import sys print 'Args: ', sys.argv[1:] EOF 

Output:

 Args: ['1', '2', '3'] 

Argument - tells Python to read the script from standard input. Everything between <<EOF and EOF comes as standard input in Python. Note that this means that you cannot read standard input from a script using raw_input and similar functions.

0
source

Source: https://habr.com/ru/post/1395640/


All Articles