diff options
author | Arjun Satarkar <me@arjunsatarkar.net> | 2023-05-24 16:47:46 +0000 |
---|---|---|
committer | Arjun Satarkar <me@arjunsatarkar.net> | 2023-05-24 16:47:46 +0000 |
commit | c5150be9f9f42f8928800ccf874fffa95649e7f4 (patch) | |
tree | bf038a098c467d977d763e669d2d91c494d88f88 | |
parent | 504cbcec63407d8b54ba14079a74fa48513e921f (diff) | |
download | DnDnDnD-c5150be9f9f42f8928800ccf874fffa95649e7f4.tar DnDnDnD-c5150be9f9f42f8928800ccf874fffa95649e7f4.tar.gz DnDnDnD-c5150be9f9f42f8928800ccf874fffa95649e7f4.zip |
Use nicer argument parsing
-rwxr-xr-x | main.py | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1,10 +1,11 @@ #!/usr/bin/env python3 +import argparse import sys -try: - word_num = int(sys.argv[1]) -except IndexError: - word_num = None +parser = argparse.ArgumentParser(prog="D&D&D&D", description="Dungeons & Dragons D...") +parser.add_argument("word_num", default=None, nargs="?", type=int) +args = parser.parse_args() +word_num = args.word_num WORDLIST_FILE_PATH = "corncob_lowercase.txt" |