[issue47002] argparse - "expected one argument" when used -: in argument

2022-03-13 Thread paul j3
paul j3 added the comment: '-1' and '-1.23' are recognized as numbers, and treated as arguments. '-1' requires some special handling because it is allowed as a flag, as in parser.add_argument('-1','--one') '-1:00' on the other hand is no different from a string like '-foo'. Default

[issue47002] argparse - "expected one argument" when used -: in argument

2022-03-13 Thread Pythass
Pythass added the comment: The curious aspect is that for: import argparse parser = argparse.ArgumentParser() parser.add_argument("-u", "--utc", choices=["-1"]) args = parser.parse_args() it works. But if we use the colon (:) character as: import argparse parser = argparse.ArgumentParser()

[issue47002] argparse - "expected one argument" when used -: in argument

2022-03-13 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Seems related to https://bugs.python.org/issue9334 -- nosy: +xtreak ___ Python tracker ___

[issue47002] argparse - "expected one argument" when used -: in argument

2022-03-13 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47002] argparse - "expected one argument" when used -: in argument

2022-03-13 Thread Eric V. Smith
Eric V. Smith added the comment: Here's a simplified reproducer: import argparse parser = argparse.ArgumentParser() parser.add_argument("-u", "--utc", choices=["-1:00"]) args = parser.parse_args() I assume this is related to argparse guessing if an argument is a negative number. See

[issue47002] argparse - "expected one argument" when used -: in argument

2022-03-13 Thread Pythass
New submission from Pythass : By using argparse, and by passing a string as argument that has both a dash "-" and colon ":", python returns "expected one argument" error, despite it works when I use only "-" without ":". An example of code is attached at the ticket. Examples of triggering