python_rag_system/lesson_11/home_task/task36.py
2025-10-23 09:57:04 +03:00

14 lines
989 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Инкапсуляция и property
# todo: Класс "Пользователь" (Валидация email)
# Создайте класс User. У него должны быть свойства email и password.
# При установке email проверяйте, что строка содержит символ @ (простая валидация).
# При установке пароля, храните не сам пароль, а его хеш (для простоты можно использовать hash()).
# Сделайте метод check_password(password), который проверяет, соответствует ли хеш переданного
# пароля сохраненному хешу.
# Пример использования
user = User("test@example.com", "secret")
print(user.email) # test@example.com
# print(user.password) # AttributeError
print(user.check_password("secret")) # True
print(user.check_password("wrong")) # False