This program is part of the Comparative Programming :: Echo set of examples.
Our Python example seems very familiar; many of the scripting languages have eerily similar syntax for an example this basic. The one major difference here is the use of Slices to pull our arguments out of the list of command line arguments. Python’s sys.argv (provided for us after importing the sys module) includes the name of the program script as it’s first element. We need to trim this item off and print only the remaining items on the argument list. Our ’slice’ gives us every element from the index 1 to the end of the list (remember, our list is indexed from 0).
Program Source: echo.py
From the command line:
python echo.py Hello World