Skip to content

Conversation

@eduardzapadinsky
Copy link
Owner

Adding magic methods concerning hometask

Copy link
Contributor

@shorodilov shorodilov left a comment

Choose a reason for hiding this comment

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

Потребує виправлень

01/task_01.py Outdated
return self.name

def __eq__(self, other):
return self.name == other.name and self.price == other.price
Copy link
Contributor

Choose a reason for hiding this comment

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

Додай перевірку типів. Бо це спрацює лише для порівняння з об'єктом Product.

01/task_01.py Outdated
other.products_list.index(product)
]
self.add_product(product, count)
return self
Copy link
Contributor

Choose a reason for hiding this comment

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

Тут ліпше створити новий об'єкт кошика і повертати його.

01/task_01.py Outdated
"""Adding products to the cart"""

if product in self.products_list:
self.products_count[
Copy link
Contributor

Choose a reason for hiding this comment

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

Ліпше розбивай таке на декілька рядків, або слідуй PEP-8.
Тут все вірно, але у мене очі слізяться коли таке бачу.

01/task_01.py Outdated
if isinstance(other, Product):
self.add_product(other, 1)
elif isinstance(other, ShoppingCart):
for product in other.products_list:
Copy link
Contributor

Choose a reason for hiding this comment

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

Он же ж тип нормально використовуєш zip ніжче...

@eduardzapadinsky
Copy link
Owner Author

Додав перевірку типів в eq. Створив новий об'єкт кошику. Додав окремо рядок для індексу. Змінив на zip в add.

@shorodilov shorodilov self-requested a review December 5, 2022 12:08
Copy link
Contributor

@shorodilov shorodilov left a comment

Choose a reason for hiding this comment

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

lgtm

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.

3 participants