1
./hello_world -c arg1 arg2 arg3

Is it possible to code so that option -c would only get two arguments (arg1 and arg2)?

parser.add_option("-c",
                  action="append2",        <--- maybe something like that?
                  dest="verbose",
                  help="make lots of noise [default]")

1 Answer 1

2

You can use the nargs attribute.

For example:

parser.add_option("-c", nargs=2, dest="verbose", help="make lots of noise [default]")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.