So I have some code that has way too many of these in it
try:
if argv[4]:
n = argv[4]
except IndexError, e:
n = raw_input("Enter n: ")
Is there some easier way to do this?
Basically a better way to check for input to exists and then if it doesn’t act accordingly.
Thanks
Have a look at the
argparsemodule (which does a lot more than is shown here):