Course Content
In-Depth Python OOP
In-Depth Python OOP
4. Polymorphism and Abstraction
Challenge: AuthMixin
Task
Swipe to begin your solution
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.
Solution
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 4. Chapter 3
Challenge: AuthMixin
Task
Swipe to begin your solution
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.
Solution
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 4. Chapter 3
Switch to desktop for real-world practiceContinue from where you are using one of the options below