Skip to content

Conversation

@eyuell21
Copy link

@eyuell21 eyuell21 commented Aug 8, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Python implementation of Cowsay.

Questions

Ask any questions you have for your reviewer.

@eyuell21 eyuell21 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 8, 2025
@DaryaShirokova DaryaShirokova added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 17, 2025

# Dynamically call the animal function (like cowsay.turtle("hello"))
try:
animal_func = getattr(cowsay, args.animal)

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).

Copy link
Author

Choose a reason for hiding this comment

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

Noted, Thank you 🙏

try:
animal_func = getattr(cowsay, args.animal)
output = animal_func(message)
print(output)

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 :) )

@DaryaShirokova DaryaShirokova added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 17, 2025
animal_func = getattr(cowsay, args.animal)
output = animal_func(message)
print(output)
if output is not None:

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?

Copy link
Author

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.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants