3 ms·
I largely find argparse to be OK apart from a couple of issues. First, it allows the user to abbreviate flags. They can pass --fl and it will be interpreted as
by aepiepaey 8y ago
I largely find argparse to be OK apart from a couple of issues.
First, it allows the user to abbreviate flags. They can pass --fl and it will be interpreted as --flag, assuming no other flag shares the same prefix.
This sucks for maintainability: add a new flag and any abbreviation for a previously existing flag that shares the same prefix will now stop working, breaking user workflows.
Since Python 3.5 there's the allow_abbrev parameter that allows disabling this behaviour, but then you also lose the ability to combine multiple single-character flags (so you can't pass e.g. '-Ev' any more, and would have to pass '-E -v' instead[1].
The other issue is that it's tedious to keep all the .add_argument calls readable, while maintaining a reasonable maximum line length.
[1]: https://bugs.python.org/issue26967 https://bugs.python.org/issue26967