Pythonic arguments
We should know by now that we will want to pass command-line arguments to Python and we can do this using the argv
array. However, we are more like bash; with Python we combine the program name into the array with the other arguments.
Python also uses lowercase instead of uppercase in the object name:
- The
argv
array is a part of thesys
object sys.argv[0]
is the script namesys.argv[1]
is the first argument supplied to the scriptsys.argv[2]
is the second supplied argument and so on- The argument count will always be at least 1, so, keep this in mind when checking for supplied arguments