Add angle brackets for required args in argparse

scruel tao scruelt at hotmail.com
Wed Feb 15 02:33:37 EST 2023


If we have the following code:
```
parser = argparse.ArgumentParser(description="test")
parser.add_argument('path')
```

Run it without args, will get error message:
```
usage: test.py [-h] path
test.py: error: the following arguments are required: path
```

However, I hope the message can be as the following:
```
usage: test.py [-h] <path>
test.py: error: the following arguments are required: path
```

Or might can consider to provide a way to let user have there own style, like:
```
usage: test.py [-h] path
```

Thanks.



More information about the Python-list mailing list