Example #1
0
def cli():
    parser = argparse.ArgumentParser(prog='wordcount', description='Count all the words!')
    parser.add_argument('-t', '--topcount', dest='command',
                        action='store_const', const=top_words, default=count_words,
                        help='Show most frequent words.')
    parser.add_argument('textfile', type=argparse.FileType(), help='Text file to be counted.')

    option = parser.parse_args()

    print(option.command(read_words(option.textfile)))
Example #2
0
def cli():
    parser = argparse.ArgumentParser(prog='wordcount',
                                     description='Count all the words!')
    parser.add_argument('-t',
                        '--topcount',
                        dest='command',
                        action='store_const',
                        const=top_words,
                        default=count_words,
                        help='Show most frequent words.')
    parser.add_argument('textfile',
                        type=argparse.FileType(),
                        help='Text file to be counted.')

    option = parser.parse_args()

    print(option.command(read_words(option.textfile)))
Example #3
0
 def read_words(self):
     self.words = read_words(askopenfile())
     self.show_words()
Example #4
0
 def read_words(self):
     self.words = read_words(askopenfile())
     self.show_words()