I was wondering how would you pass and then retrieve a list of numbers to a script using this syntax:
python3 program.py < 1 2 3 4
I know I can pass arguments using the following syntax:
python3 program.py 1 2 3 4
And then retrieve the arguments using sys.argv
:
print(sys.argv) # a list of arguments
I have seen around, but for some reason I was not able to do it.
Note that I am wondering if it's possible or not, I am not asking ways to read from the standard input that are different from my first example above.