Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #197577
| From | Lawrence D’Oliveiro <ldo@nz.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: argsparse: allowing --version without mandatory options |
| Date | 2025-10-30 21:57 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <10e0n10$n2t$10@dont-email.me> (permalink) |
| References | <87bjlod7g3.fsf@zedat.fu-berlin.de> |
On Thu, 30 Oct 2025 11:12:28 +0100, Loris Bennett wrote: > I am writing a program for the command-line which uses 'argsparse'. I > want to make some options mandatory by setting 'required=True', but > still allow the program to run with the option '--version' (which just > shows the version and then exits) even if the mandatory options are > missing. > > Is there a standard way of doing this? Crusty curmudgeon here, still sticking to good old getopt. It may be simple, crude even, but on the other hand it doesn’t try to do too much. It may be “soft-deprecated”, but at least that means it will keep on doing what it does for the foreseeable future. It doesn’t offer built-in help, but then I also like to write man pages (yes, proper documentation) for my more complex scripts.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar
argsparse: allowing --version without mandatory options "Loris Bennett" <loris.bennett@fu-berlin.de> - 2025-10-30 11:12 +0100
Re: argsparse: allowing --version without mandatory options "Loris Bennett" <loris.bennett@fu-berlin.de> - 2025-10-30 13:50 +0100
Re: argsparse: allowing --version without mandatory options "Jonathan N. Little" <lws4art@gmail.com> - 2025-11-03 22:19 -0500
Re: argsparse: allowing --version without mandatory options Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-30 21:57 +0000
csiph-web