-
-
Notifications
You must be signed in to change notification settings - Fork 42
London | 25-SDC-July | Eyuel Abraham | Sprint 4 | Implementing cowsay #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| # Dynamically call the animal function (like cowsay.turtle("hello")) | ||
| try: | ||
| animal_func = getattr(cowsay, args.animal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check out an alternative get_output_string method here to avoid getattr (not the best choice to use if there is alternative - it make code more readable).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted, Thank you 🙏
implement-cowsay/cow.py
Outdated
| try: | ||
| animal_func = getattr(cowsay, args.animal) | ||
| output = animal_func(message) | ||
| print(output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You program always prints none in the end, please debug why this is and fix (should be a simple fix :) )
…ad of returning output
| animal_func = getattr(cowsay, args.animal) | ||
| output = animal_func(message) | ||
| print(output) | ||
| if output is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So can you explain in which cases the output is None here and when it is not None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Output is None only if the animal function doesn't return anything. In the official cowsay module, it always returns a string.
The output is not None in normal cases because standard cowsay animal functions return a string of ASCII art.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it print None when you remove if output is not None:? What is considered to be not a normal case?
Learners, PR Template
Self checklist
Changelist
Python implementation of Cowsay.
Questions
Ask any questions you have for your reviewer.