Skip to content

level_1#1

Open
mishakov1c wants to merge 2 commits intomainfrom
level_1
Open

level_1#1
mishakov1c wants to merge 2 commits intomainfrom
level_1

Conversation

@mishakov1c
Copy link
Owner

No description provided.

if username in BANNED_USERNAMES:
return HttpResponse('User banned')
else:
return HttpResponse('User not banned')
Copy link

Choose a reason for hiding this comment

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

Тут ты в ифе не только сообщение выбираешь, но и копипастишь тип ответа и делаешь два ретурна. В этом случае будет лучше, если ты ифом будешь только текст ответа выбирать, а формирование и возврат ответа будет один раз уже после ифа.

А ещё можно воспользоваться тренарным оператором вместо ифа, будет ещё чище и понятнее.

'Октябрь',
'Ноябрь',
'Декабрь'
][month_number - 1]
Copy link

Choose a reason for hiding this comment

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

Форматирование не очень. Вынеси список в отдельную переменную, тогда будет нормас. А ещё можешь глянуть модуль calendar, авось там найдётся чего полезного :)

def get_month_title_by_number(month_number: int):
pass # код писать тут
locale.setlocale(locale.LC_ALL, "ru_RU")
months = list(calendar.month_name)
Copy link

Choose a reason for hiding this comment

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

Тут list лишний


def get_month_title_by_number(month_number: int):
pass # код писать тут
locale.setlocale(locale.LC_ALL, "ru_RU")
Copy link

Choose a reason for hiding this comment

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

А вот это неправильно: сейчас у тебя функция получения названия месяца неявно меняет локаль, это не очень.

Когда мне надо временно переопределить локаль, а потом вернуть старую, я вот этим способом пользуюсь: https://stackoverflow.com/questions/50737783/

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

Comments