We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal example application:
from traitlets.config import Application from traitlets import Unicode class TestDash(Application): test = Unicode().tag(config=True) aliases = { "test": "TestDash.test", } def initialize(self, argv=None): self.parse_command_line(argv) def start(self): print(self.test) if __name__ == '__main__': app = TestDash() app.initialize() app.start()
Just a number works:
$ python tool.py --test -1 -1
Something else does not:
$ python tool.py --test -1d usage: tool.py [-h] [--debug] [--show-config] [--show-config-json] [--test TestDash.test] [extra_args [extra_args ...]] tool.py: error: argument --TestDash.test: expected one argument
Quoted with space it works again:
❯ python tool.py --test "-1 d" -1 d
But not without the space:
❯ python tool.py --test "-1d" -1 d
With =, it always works:
=
❯ python tool.py --test=-1d -1d
I am not sure if this is really a traitlets limitation or if there is just no way around this.
The text was updated successfully, but these errors were encountered:
Unfortunately its a long-running issue with the standard library argparse module: some examples of discussions from a decade ago: https://bugs.python.org/issue9334 & https://stackoverflow.com/questions/16174992/cant-get-argparse-to-read-quoted-string-with-dashes-in-it. As you mentioned, --test=-1d or --test " -1d" are possible ways to work around it.
argparse
--test=-1d
--test " -1d"
Sorry, something went wrong.
No branches or pull requests
Minimal example application:
Just a number works:
Something else does not:
Quoted with space it works again:
But not without the space:
With
=
, it always works:I am not sure if this is really a traitlets limitation or if there is just no way around this.
The text was updated successfully, but these errors were encountered: