Hello.
Having some difficulties with a script. Here's the relevant part:
Code:
if sys.argv[1] == '-dir':
convertDirectory(sys.argv[2])
elif sys.argv[1] == '--help':
showUsage()
elif string.count(sys.argv[1], '.mp3') == 1:
convertSong(sys.argv[1])
else:
showUsage()
What I want is if no command line arguments are given, the usage details are shown. When I test it with no arguments however, I get an error telling me that sys.argv[1] is out of range, which is true: it doesn't exist, which is kinda the point.
The traceback shows the error at the 'if sys.argv[1] == '-dir': ' line, but everything else works as it should.
I tried testing for sys.argv[1] ie: elif sys.argv[1] == 0 but always get the out of range error.
What am I doing wrong here?