[issue45673] argparse error with option with optional value
paul j3
report at bugs.python.org
Tue Nov 2 13:17:19 EDT 2021
paul j3 <ajipanca at gmail.com> added the comment:
This is too big of an example for this board; I think it should have been asked on StackOverFlow. Or maybe trimmed do to a more compact example.
But in any case, this is normal behavior for argparse. Type checking, here 'int', is done after the string is allocated to the '-s' argument.
Reserving that string for the required positional requires a form of look ahead that argparse does not currently do. I think there's an old bug/issue on the topic, but the fix was, if I remember correctly, too complex to simply drop in.
I may look that up later.
----------
nosy: +paul.j3
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45673>
_______________________________________
More information about the Python-bugs-list
mailing list