May-15-2019, 06:51 PM
(May-15-2019, 06:03 PM)2skywalkers Wrote: For example python test_file_name.py -t hiSure but i don't use argparse,i can show you an other way with Click.
Then it prints "hi"
I like the "-" as its what is used in linux a lot.
argparse is't bad it work well,just that i think Click dos a lot stuff better.
import click @click.command() @click.option('-t', '--string-to-echo', 'string') def echo(string): click.echo(f'{string} or backwards {string[::-1]}') if __name__ == '__main__': echo()
Output:λ python hello.py -t hello
hello or backwards olleh
A look at Click i had i while ago.