-1

I want the argparse cli parameter to use "=" sign when i'm giving the list of the arguments with a space between them.

For example:

--repos= repo1 repo2 repo3

but when i'm giving the parameters in this way i'm getting the following exception "error: unrecognized arguments: repo1 repo2 repo3"

Is there a way to pass the '=' to the parameter?

  • Typically this would be `--repos repo1 --repos repo2 --repos repo3`, then you can use `action='append'`. Or do `--repos=repo1,repo2,repo3` or `--repos='repo1 repo2 repo3'` then split it in e.g. a custom `type`. – jonrsharpe Feb 17 '23 at 12:15
  • drop the '=' and use a `nargs` parameter. – hpaulj Feb 17 '23 at 15:49

1 Answers1

0

you can pass the '=' sign to the parameter by enclosing the argument that follows the '=' sign in quotes. For example:

--repos="repo1 repo2 repo3"

This will pass "repo1 repo2 repo3" as a single argument to the --repos option.

Tasa
  • 1
  • 2