Created
July 27, 2023 21:32
-
-
Save hoehermann/08d56f62a0b04e88697feba2f362884b to your computer and use it in GitHub Desktop.
Revisions
-
hoehermann created this gist
Jul 27, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ import argparse parser = argparse.ArgumentParser() parser.add_argument('--format', required=True, choices=['binary', 'xml', 'text']) args, rem_args = parser.parse_known_args() if (args.format == "text"): parser.add_argument('--encoding', required=True) parser.parse_args(rem_args, namespace=args) # this does not work since required argument has already been consumed