This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients Tristan.Fisher, paul.j3
Date 2014-09-26.03:40:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1411702853.61.0.523322839452.issue22500@psf.upfronthosting.co.za>
In-reply-to
Content
A 'store_true' action takes 0 arguments.  In effect `nargs=0`.

With an `optional` (flagged) argument, the default `False` is used if the flag is absent, and set to `True` when the flag is encountered (its Action `__call__` function is run).

A `positional` is 'encountered' whenever there are enough values to meet its `nargs`.  With `nargs=0`, an empty list of strings, i.e. none, is enough.  Thus such a `positional` is always found, and its `__call__` is run, setting the value to `True`.

As a result, action types like 'store_true', 'store_false', 'store_const' only make sense with `optionals`.

And I can't think of simple way of using a 'positional' to set an Namespace 'dest' to boolean values.  It could be done with a custom Action, but not with the predefined ones.  Or you could translate the values after parsing.
History
Date User Action Args
2014-09-26 03:40:53paul.j3setrecipients: + paul.j3, Tristan.Fisher
2014-09-26 03:40:53paul.j3setmessageid: <1411702853.61.0.523322839452.issue22500@psf.upfronthosting.co.za>
2014-09-26 03:40:53paul.j3linkissue22500 messages
2014-09-26 03:40:53paul.j3create