Skip to content
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

'Solution' #1630

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

'Solution' #1630

wants to merge 2 commits into from

Conversation

nagafochfv
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Thank you for your hard work on this project! 😊 While your implementation of the Person class and the create_person_list function is mostly correct, there are a couple of critical issues that need to be addressed before we can approve the pull request:

  1. Handling Non-Unique Names: The use of a class variable people to store instances of Person by name can lead to issues if names are not unique. This could cause unexpected behavior or data overwriting. Consider using a unique identifier, such as an ID, to ensure each person is stored uniquely.

  2. Error Handling for Missing Spouse: The current logic for setting 'wife' and 'husband' attributes assumes that these names will always be present in the Person.people dictionary. If a name is not found, None will be set, which might not be the desired behavior. Adding error handling for cases where the spouse is not found will make your code more robust and reliable.

Addressing these issues will significantly improve the functionality and reliability of your code. Keep up the great work, and I look forward to seeing the improvements! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

app/main.py Show resolved Hide resolved
app/main.py Outdated Show resolved Hide resolved
Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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


Great job on implementing the Person class and the create_person_list function! 🎉 While your code meets the basic requirements, there are a few critical areas for improvement:

  1. Handling Non-Unique Names: Although the task specifies that all names are different, it's good practice to consider scenarios where names might not be unique. Using a unique identifier, like an ID, can help prevent potential issues.

  2. Error Handling for Missing Spouse: Your current logic assumes that spouse names will always be present in the Person.people dictionary. To avoid potential errors, consider using the dict.get() method for accessing spouse names. This will make your code more robust and prevent KeyError exceptions.

  3. Use of List Comprehension: Refactor the create_person_list function to use list comprehension. This will make your code more concise and Pythonic.

These improvements will enhance the functionality and reliability of your code. Keep up the good work, and remember to review the comments to refine your solution. Addressing these issues will help you avoid similar problems in the future and strengthen your coding skills. Keep learning and improving! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

@@ -1,8 +1,29 @@
class Person:
# write your code here
pass
people = {}

Choose a reason for hiding this comment

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

Using a class variable people to store instances by name can lead to issues if names are not unique. Consider using a unique identifier, such as an ID, to ensure each person is stored uniquely.

Comment on lines +18 to +28
wife = Person.people.get(pers["wife"])
if wife:
setattr(person, "wife", wife)
else:
setattr(person, "wife", None)
if "husband" in pers and pers["husband"] is not None:
husband = Person.people.get(pers["husband"])
if husband:
setattr(person, "husband", husband)
else:
setattr(person, "husband", None)

Choose a reason for hiding this comment

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

The current logic for setting 'wife' and 'husband' attributes assumes that these names will always be present in the Person.people dictionary. If a name is not found, None will be set, which might not be the desired behavior. Adding error handling for cases where the spouse is not found will make your code more robust and reliable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants