Homework: wc Clone
作业: wc 克隆
A clone of Unix wc. Five functions: three counters, one orchestrator, one parser.
The five functions
count_lines(path)— intcount_words(path)— intcount_chars(path)— int (includes newlines)count_all(path)— tuple, calls the three aboveparse_args(argv)— argparse with path + 3 flags
The shape
Python · runnable
Acceptance criteria
- All 8 tests pass
- Each counter uses
with open(...) count_allcalls at least 2 of the 3 countersparse_argsacceptspath+--lines/--words/--chars