0

I am using argparse. Let's say i want to run a python script with 2 mandatory arguments and for each argument, i also include the option (-flag). Something like below:

$ python test.py -arg1 abc -arg2 xyz 

Also, is it possible to allow 2 flag names (short and long names) say -arg1 and -a1?

1
  • Mandatory arguments should be positional: test.py abc xyz. It is troubling to identify mandatory arguments from the named argumens in the usage listing. Commented Oct 17, 2018 at 5:02

1 Answer 1

1

Something like:

parser.add_argument('--abc', '-a', required=True)
parser.add_argument('--xyz', '-x', required=True)
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.