Skip to content

Commit

Permalink
erase __set__ n __get__ atributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Greshch committed Dec 10, 2024
1 parent 3943c6d commit c3e2a8d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def create_person_list(people: list) -> list:
for person in people:
obj = Person(person["name"], person["age"])
partner = "wife" if "wife" in person else "husband"
obj.__setattr__(partner, person[partner])
setattr(obj, partner, person[partner])
persons.append(obj)

for person in persons:
partner = "wife" if hasattr(person, "wife") else "husband"
key = person.__getattribute__(partner)
key = getattr(person, partner)
if key is None:
person.__delattr__(partner)
delattr(person, partner)
else:
obj = Person.people[key]
person.__setattr__(partner, obj)
setattr(person, partner, obj)
return persons

0 comments on commit c3e2a8d

Please sign in to comment.