Argument parser for a word count and/or line count program
Do you notice something fishy on this line?


print "Words in a file: {}" .format(print_words(args.filename))



If I highlight just the fishy part:


print print_words(...)



The fishy part is printing something returned by print_words.
The name of print_words suggests that it prints something.
And printing functions typically don't return a value.
So this is all very confusing.

My guess is that print_words doesn't actually print words,
but returns a word count. So a name like get_word_count would be less confusing.
The same goes for print_lines.

With these suggested renames, now we can introduce some real printing functions, and make the code more DRY:

if args.words:
    print_words(args.filename)

elif args.lines:
    print_lines(args.filename)

else:
    print_words(args.filename)
    print_lines(args.filename)


It won't get much DRY-er than this, and I don't think it needs to.