Skip to content
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
implement-cowsay/.venv.
14 changes: 14 additions & 0 deletions implement-cowsay/cow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import cowsay # type: ignore
import argparse

parser = argparse.ArgumentParser(description="Make animals say things")
parser.add_argument('--animal', choices=cowsay.char_names, help="The animal to be saying things", default="cow")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a problem, but is a bit unusual to have mixed quotes (some of the strings on this line are wrapped in 's and others "s) - is there a reason to prefer one over the other? Or a reason you used different ones here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to be honest. Python accept both. I know I should pick one and be consistent with it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense :) Personally I prefer "s because it's more often that I write a string containing a ' than a ", e.g. I will often write a string literal like "I don't know" but I less often write a string literal like 'I said "hello"'

parser.add_argument('message', nargs='+', help="The message to say")

args = parser.parse_args()

char_name = args.animal
message = ' '.join(args.message)

cowsay_func = getattr(cowsay, char_name)
cowsay_func(message)
1 change: 1 addition & 0 deletions implement-cowsay/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cowsay