# [[Python argparse]]
_Created: 2025-06-24_ | #python | [[025 Python MOC|Python]]
## Notes
### Using defaults in positional parameters
The `default` parameter for positional parameters only works when `nargs` is set to `?`, which means the argument is optional and can appear zero or one time. Otherwise the default of `nargs` is `None`, which means the argument must appear once and only once.
```python
parser = argparse.ArgumentParser()
parser.add_argument(
"command",
help="command to run",
nargs="?",
default="main",
choices=["main", "init"],
)
args = parser.parse_args()
```