I'm writing a script where I extract command line arguments using getopt, qualify the values offered, then use those values as limits on a loop. Code fragment is below:
try:
start_pod, end_pod, topo_value = map(int, args)
except ValueError, error_msg:
if 'invalid' in str(error_msg):
err_funct('Non-integer values supplied: {%s}' % args)
else:
err_funct(error_msg)
for pod in range(start_pod, end_pod):
print 'value of pod: %s' % pod
for switch in range(1,5):
print 'value of switch: %s' % switch
The problem I am having is with the 'range' function. I think I am passing it integers (the map function is converting a list of strings to integers) and if I wasn't my try/except handler exits by way of an error function I wrote, but for some reason this isn't working.
If I call my script with the correct number of inputs, e.g. 'some_script.py 1 1 5', the script returns nothing.