Re: argsparse: allowing --version without mandatory options
"Peter J. Holzer" <[email protected]>
| Newsgroups | gmane.comp.python.general |
|---|---|
| Message-ID | <pxz34yon2qw7wspicq3h374qxvh4rljjx6ujghhlfnhfzdmmsk@usnhydobdftt> |
On 2025-10-30 13:47:16 -0400, [email protected] wrote: > On 2025-10-30 at 13:50:42 +0100, > Loris Bennett <[email protected]> wrote: > > "Loris Bennett" <[email protected]> writes: > > > I am writing a program for the command-line which uses 'argsparse'. I > > > want to make some options mandatory by setting 'required=True', but [...] > Don't take this the wrong way, but what, exactly, is a mandatory option? > Mandatory and optional are quite opposite. If you have mandatory > arguments, then make the arguments mandatory. If you have optional > options, then make the options optional. Otherwise, as a user, I just > have extra typing (i.e., the "--whatever" before the mandatory argument) > to type (redundancy intended). As a user, you also get safety from that redundancy. It's easy to mix up the order of positional arguments, especially if there are more than two or three of them. If you have to name each argument, that risk is significantly reduced. hjp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | [email protected] | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!"
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmkHnKsACgkQ8g5IURL+ KF1MeQ//f/suvya1iAVFSvNqaPx9DlCJD3B8VratzKfGF05XZtc0DIg1f9I7CqqX n3GYZwgXohLsieFPcbohSHzNPy+Bk7I4ZuF2QrbfDlCcGqoAsFi/e6EXPJOeJQ9V Li7Jrd/OowmMyX5syaMgMed2YVPpWVpYP2AOXzY0LS/GrjpnO8lp896wAXJccFDM o9dg868BN7KqCMvlgTflCF6ED8ZXF+HRGyaK8ykKCyKRAs4mQntGcGOej9DFYGLx PSp4FOxyWnXra5AlGmNfKqEyplu37A3c0J16Ut/5g0HOAkhROs8USWHNYL/by4s4 OUhBtfIAvqRaIN2S3eeSp1UwsDqnyX+i+8VJVBxQ4l5VIHtonn2iwYIMCHFpQLVa 7rOGic0HqnWqMh9K5deMYyfzpBbtGHSp0ThlkFN4Zsr4LjyQgKwJWxi2HfCYXRxn 4vp8DgoEqqC4MojpFud6Nfxn9nFaYR/J5uMVmOQlmH0MxUXOQfJBBZksiXyO1Bfr rDOMC1M6UlRO/nvw2Yl1U8UYXJFVmsIWdOzWVNalG3DNYroNS1CL0dBVki1t9yiW X79thtBNsonzw4ivbjQFI0KTqw542tSwgYMmDQJ7hLQSIm1V7067H8fq0hQunnJZ fR+OWS0DmkRACXuysMwGJ44fLHf21RR0jaaRDuaAf2NTHd77At8= =AKo9 -----END PGP SIGNATURE-----