Summary
Now, look at the code that you have written and describe this for yourself:
pythonfrom abc import ABC, abstractmethodclass AuthMixin:is_authenticated = Falsedef login(self, taken_password):if self.password == taken_password:self.is_authenticated = Trueprint(f"{self.username} is authenticated")else:print("Wrong password!")def logout(self):self.is_authenticated = Falseprint(f"{self.username} is loggouted")class AbstractAdmin(ABC):@abstractmethoddef login():pass@abstractmethoddef logout():pass@abstractmethoddef create_content():pass@abstractmethoddef update_content():pass@abstractmethod
You can understand this code with 85 lines. Congratulations!
You have mastered Object-Oriented Programming in Python and can use the necessary functionality!
1. Remember all OOP concepts:
2. What are magic methods?
Grazie per i tuoi commenti!