That code works just fine, assuming that you actually give it three arguments to unpack, as with:
c:\pax> python yourProg.py A B C
the script is: yourProg.py
the first variable is: A
the second variable is: B
the third variable is: C
The problem occurs when you don't give it enough arguments:
c:\pax> python yourProg.py A
Traceback (most recent call last):
File "yourProg.py", line 2, in
script, first, second, third = argv
ValueError: not enough values to unpack (expected 4, got 2)
If you want to ensure there are enough arguments before trying to unpack them, you can use len(argv)
to get the argument count, and compare that to what you need, something like:
import sys
if len(sys.argv) != 4:
print("Need three arguments after script name")
sys.exit(1)
script, first, second, third = sys.argv
print ("the script is:", script)
print("the first variable is:", first)
print("the second variable is:", second)
print ("the third variable is:", third)