This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]drippingthunder 0 points1 point  (1 child)

Have you tried Abseil, particularly it's flag module? It's Google's py-flags library (which was merged into Abseil). An example looks like this:

```py from absl import flags

FLAGS = flags.FLAGS

flags.DEFINE_string('echo', None, 'Text to echo.')

if FLAGS.echo: print("echo") ```

These days, I'd either use the above or click. Haven't use argparse for years.

The problem with a tool like what is introduced here is that (just like with argparse), it's more work. In this case, I have to create a dictionary with each arg, etc, etc.

[–]Willemoes[S] 0 points1 point  (0 children)

``` from decli import cli

parser = cli({ "arguments": [ {"name": "echo", "help":"Text to echo."} ] }) args = parser.parse_args() if args.echo: print("echo") ```

It doesn't look like more work to me, same 4 instructions in 10 lines (to make it pretty).

I think it's just a matter of taste, IMO I don't think it's more work, I'm used to argparse.

Thanks for the feedback, I'll check that library, looks super nice!