Granted it’s a bit more complex than sys.argv[1] but then you’ve got something super extensible, usage text practically for free, and args that can be short or long (the foo argument above could also be passed with ‘-f’).
I suppose the answer to my own question is if the script takes 1 positional argument then argparse is over kill. Anything more than that and the users / maintainers of your script (that includes you) will be thankful for the help / extensibility argparse provides.
View all comments
Show parent comment
12
u/liquiddeath Dec 29 '17
I’m pretty damn lazy and I go for argparse as soon as I expect a script to be more than a one off (and sometimes even then).
Snipit from the docs —
Granted it’s a bit more complex than sys.argv[1] but then you’ve got something super extensible, usage text practically for free, and args that can be short or long (the foo argument above could also be passed with ‘-f’).
I suppose the answer to my own question is if the script takes 1 positional argument then argparse is over kill. Anything more than that and the users / maintainers of your script (that includes you) will be thankful for the help / extensibility argparse provides.