Kursinhalt
In-Depth Python OOP
In-Depth Python OOP
4. Polymorphism and Abstraction
Challenge: AuthMixin
Aufgabe
Swipe to start coding
Let's make your code more flexible.
- Define the
AuthMixin
class. - Cut the
login
andlogout
methods from theUser
class and insert them into theAuthMixin
body. - Move the
is_authenticated
class attribute to theAuthMixin
. - Inherit the
User
class from theAuthMixin
.
Note
After performing all the actions, you will have an authorization mixin (
AuthMixin
) that can be used for different user classes.
Lösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 4. Kapitel 3
Challenge: AuthMixin
Aufgabe
Swipe to start coding
Let's make your code more flexible.
- Define the
AuthMixin
class. - Cut the
login
andlogout
methods from theUser
class and insert them into theAuthMixin
body. - Move the
is_authenticated
class attribute to theAuthMixin
. - Inherit the
User
class from theAuthMixin
.
Note
After performing all the actions, you will have an authorization mixin (
AuthMixin
) that can be used for different user classes.
Lösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 4. Kapitel 3