예제 #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)))
예제 #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)))
예제 #3
0
 def read_words(self):
     self.words = read_words(askopenfile())
     self.show_words()
예제 #4
0
 def read_words(self):
     self.words = read_words(askopenfile())
     self.show_words()