June 2000
Intermediate to advanced
556 pages
8h 45m
English
We already encountered the sys module when we printed out the path variable as part of the Python existence proof in chapter 2. The sys module provides the variable argv for accessing command-line arguments. The argv variable is an example of a Python list. A list is simply an ordered collection of objects. Lists are delimited by square brackets, and items in a list are separated by a “,”. Here is a list consisting of integers 1, 2, and 3.
CD-ROM reference=7001.txt [1,2,3]
Here is a list consisting of the string "Hello", the floating point number 3.14, and the integer 1.
CD-ROM reference=7002.txt ["Hello",3.14,1]
The argv variable is a list of strings–one for each command-line argument. When Python is executed ...
Read now
Unlock full access