Skip to main content

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

This version

0.0.1

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)

Uploaded Source

Built Distribution

simple_parsing-0.0.1-py3-none-any.whl (2.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page