[issue45673] argparse error with option with optional value

2021-11-02 Thread paul j3
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

[issue45673] argparse error with option with optional value

2021-11-02 Thread Paolo Benvenuto
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

[issue45673] argparse error with option with optional value

2021-11-02 Thread paul j3
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

[issue45673] argparse error with option with optional value

2021-11-02 Thread paul j3
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

[issue45673] argparse error with option with optional value

2021-10-29 Thread Paolo Benvenuto
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",