I just read the article but still have a couple of questions. In the article, "In this case parse_args() will place all arguments in a tuple. I.e. after we run parse_args(), opt.multi will be a tuple containing all arguments that user has passed to our program."
1. So if I need to get the arguments in the program, can we just use a=opt.multi[1], b=opt.multi[2] etc?
2. If I want to have an optional argument in the end, e.g. without this argument program should proceed another way, is optparse working in this situation?Thanks a lot!
1. tuples are numbered from 0, so it will be opt.multi[0] and opt.multi[1]. Note that one seldom needs options with multiple arguments.
2. If you mean an argument which is not part of an option, your program must examine the content of the list args in opt, args = parser.parse_args()
.
Write a few test scripts to experiment with optparse, it's the best way to see how it works.