Oscar Benjamin writes:
 > On Fri, 26 Feb 2021 at 02:49, Stephen J. Turnbull
 > <turnbull.stephen...@u.tsukuba.ac.jp> wrote:

 > > Thing is, this "mutual inclusion" condition isn't really about parsing
 > > (ie, syntax)[1]; this is about semantics -- like all input validation.
 > > I don't object to having it in argparse, but it's going to be so
 > > domain-dependent that I don't think we should do more than provide
 > > hooks to validate individual arguments (eg, a 0 <= p <= 1 constraint
 > > on probabilities or proportions), and an args.validate hook to do
 > > cross-argument validation.
 > 
 > Given that the hook would just be called after parsing the args would
 > be the advantage of using a hook compared to just validating the args
 > yourself after calling parse_args?

"Quis custodiat ipsos custodes?"  That is, it has no extra value in
validating the args, but by providing a standard place to put
validation code, it helps us to validate the validators.  For most of
my scripts, I'm not going to write *any* command line validation code,
but for programs called by other tools, I think it would be helpful to
me to have all command line validation in one standard place.

We could even have a tool in argparse to report which arguments have
validators and which don't, though that smells like overkill (and I
myself would probably write it as a search in Emacs Lisp rather than
use an argparse-provided tool).

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/A22OJJSJOZ33ITLOBXLASK37LU3IB67Y/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to