paul j3 added the comment:
Put the required positional first
$ myapp myfile -s
or one of the store_true arguments
$ myapp -s -j myfile
I think
$ myapp -s -- myfile
will work as well, but that needs to be tested.
The '-s' has to be followed by something won't be confused for an
Paolo Benvenuto added the comment:
> As a general rule, don't use `nargs` like this where there's ambiguity as to
> how many values will be allocated to the argument.
What could I use instead of nargs?
--
___
Python tracker
paul j3 added the comment:
https://bugs.python.org/issue9338
argparse optionals with nargs='?', '*' or '+' can't be followed by positionals
As you can see this is an old issue, but still too big for a quick fix.
As a general rule, don't use `nargs` like this where there's ambiguity as to
paul j3 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
New submission from Paolo Benvenuto :
I'm using argparse with this code:
parser = argparse.ArgumentParser(
description='Scan a media tree in order to generate cache files suitable
for showing a beautiful web gallery',
)
parser.add_argument(
"config_file_or_album_path",