Skip to content

Level 2#2

Open
sleepwalkcapsule wants to merge 3 commits intomainfrom
level_2
Open

Level 2#2
sleepwalkcapsule wants to merge 3 commits intomainfrom
level_2

Conversation

@sleepwalkcapsule
Copy link
Owner

No description provided.

Copy link

@vppuzakov vppuzakov left a comment

Choose a reason for hiding this comment

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

👍 тут тоже аппрув, по заданию все верно. вмерживай (только сначала вмержить надо первое задание)
💡 по комментам в рамках следующего ПР лучше отработать

"""

class User:
def __init__(self, username: str, user_id: int, name: str):

Choose a reason for hiding this comment

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

💡 укажи аннотацию иниту на выход тоже

def make_username_capitalized(username: str):
return username.capitalize()

def make_username_capitalized(self):

Choose a reason for hiding this comment

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

👍 в целом верно
💡 нужна аннотация на выходное значение
💡 так как метод уже внутри класса можно переименовать в get_capitalized_username
💡 также можно использовать property

def generate_short_user_description(username: str, user_id: int, name: str):
return f'User with id {user_id} has {username} username and {name} name'

def generate_short_user_description(self):

Choose a reason for hiding this comment

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

👍 тоже верно все - спрятали в класс, убрали атрибуты - используем поля класса
💡 можно в том числе и переименовать метод во что-то более ясное, учитывая что мы уже находимся внутри класса User

pass # код писать тут

if __name__ == '__main__':
user = User(username='login', user_id=1, name='first_name')

Choose a reason for hiding this comment

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

👍

Choose a reason for hiding this comment

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

💡 можешь использовать set, для поиска очень эффективно
💡 когда видишь такую конструкцию if something return True else return False - она эквивалентна сразу возврату условия return something

Choose a reason for hiding this comment

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

💡 реквестую аннотацию на возвращаемое значение

user_3 = User(first_name='Steave', last_name='Cubin',age=29)
user_4 = User(first_name='Alex', last_name='Santaros', age=25)

if user_1.should_be_banned():

Choose a reason for hiding this comment

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

💡 чтобы каждый раз не писать одну и ту же логику - сделай функцию вне класса

def check_user(user):
    if ... print else ... print

не забудь про аннотации типов

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