A small utility for simplifying and cleaning up argument parsing scripts.
Project description
Simple, Elegant Argument Parsing
When applied to a dataclass, this enables creating an instance of that class and populating the attributes from the command-line.
A simple example:
@dataclass
class Options(ParseableFromCommandLine):
a: int
b: int = 10
parser = argparse.ArgumentParser()
Options.add_cmd_args(parser)
args = parser.parse_args("--a 5")
options = Options.from_args(args)
print(options) # gives "Options(a=5, b=10)"
args = parser.parse_args("--a 1 2 --b 9")
options_list = Options.from_args_multiple(args, 2)
print(options_list) # gives "[Options(a=1, b=9), Options(a=2, b=9)]"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
simple_parsing-0.0.1.tar.gz
(1.4 kB
view hashes)
Built Distribution
Close
Hashes for simple_parsing-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b2aaa7a8556290c44c6dc77169bb7a4a7f55a36b22335a0736543651c999624 |
|
MD5 | 8e2e739596a1635c0554adf6c345f8ef |
|
BLAKE2b-256 | 98551a907702fdbf2dcc04ee7adce4b3a8a5f3b87e6bc193fb83595335280174 |