-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
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
addArgument([...],{defaultValue:0})
does not work
#22
Comments
@hpaulj thanks a lot. Could you do it as pull requests and add tests? That will greately speedup accepting fixes. |
On Sun, Dec 9, 2012 at 8:49 AM, Vitaly Puzrin notifications@github.comwrote:
Paul |
Ah, i see now. It worth to follow simple rules:
|
Fixed in ither commit |
Trying to set the Action
defaultValue
to a falsie viaaddArgument
does not work.The problem is with the
if (!options.defaultValue) {
test. It is supposed to detectwhen this option is not defined, but instead it rejects all falsies, including
0
.A better translation of the Python block is:
(options.defaultValue == null)
would also work, due to how==
is defined.On a related note, the
getDefault
function does not work, returningnull
all the timeIt is not called by other
argparse
code, but can be called by the user. Part of the problem is the test onaction.defaultValue
. But also thereturn action.defaultValue
only returns from the inner function, not outer one.In looking for other uses of
defaultValue
, I found an error inActionContainer._registryGet
. It incorrectly translates the Pythondefault=None
optional argument. ThedefaultValue
argument in this case is not connected with the previously one. The simplest correction is to simply omit the test, since the function is always called with 3 arguments.The text was updated successfully, but these errors were encountered: