-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
Support options with optional arguments #126374
Copy link
Copy link
Closed
Labels
3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Fields
Give feedbackNo fields configured for issues without a type.
Feature or enhancement
GNU
getoptsupports options with optional arguments. For example GNUgrepcan be used with option--color=autoand with just--color. Unixgetoptdoes not need it, because it stops after encountering first nonoption argument, but GNUgetoptneeds it to support options intermixed with positional arguments.getopt.gnu_getopt()needs it for the same reason.Neither
optparsenorargparsedirectly support such kind of optional arguments. It can be supported inoptparsewith custom callback, but support of optional arguments inargparseis non-standard. In future I'm planning to add support of such kind of optional arguments inargparse, and maybe inoptparse.Linked PRs