Skip to content

2. Васильев Егор Евгеньевич. 613 - #83

Closed
ansend11 wants to merge 2 commits into
python-department:mainfrom
ansend11:hw4
Closed

ansend11 wants to merge 2 commits into
python-department:mainfrom
ansend11:hw4

Conversation

@ansend11

@ansend11 ansend11 commented Oct 2, 2026

Copy link
Copy Markdown

No description provided.

@github-actions github-actions Bot added the 613 label Oct 2, 2026
Comment thread src/part2/cart.py
"""
# TODO: реализуйте функцию
return (0, 0)
def add_to_cart(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Лучше не экономить строки и оставлять пробелы (пустые строки) между логическими блоками. Так читабельность кода улучшается.

Comment thread src/part2/cart.py
product_new[0],
product_new[1],
product_new[2],
product_new[3] - quantity,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Магические константы (для которых даже константы есть)
Пункт S3

Comment thread src/part2/cart.py
f"not enough stock for product {product_id}: {product_new[QUANTITY_INDEX]} available, {quantity} requested"
)
return None
index = next(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Надо было использовать функции из crud.py, а то в результате получилась копипаста.
Пункт S1

Comment thread src/part2/cart.py
if change is None:
cart.append((product_id, quantity))
return (product_id, quantity)
else:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Пункт Т1

Comment thread src/part2/cart.py
)
return None
product_new = read_product(storage, product_id)
if product_new == None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Пункт T3

Comment thread src/part2/crud.py
# TODO: реализуйте функцию
return 0
for cor in storage:
if cor[NAME_INDEX] == fields[0]:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Не уловил, в чем смысл названия переменной cor
Пункт M2

Comment thread src/part2/crud.py
"""
# TODO: реализуйте функцию
return 0
if len(storage) == 0:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Пункт Т4

@ansend11 ansend11 closed this Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants