Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Summary | Magic Methods
In-Depth Python OOP

book
Summary

Now, look at the code that you have written and describe this for yourself:

python
from abc import ABC, abstractmethod


class AuthMixin:
is_authenticated = False
def login(self, taken_password):
if self.password == taken_password:
self.is_authenticated = True
print(f"{self.username} is authenticated")
else:
print("Wrong password!")

def logout(self):
self.is_authenticated = False
print(f"{self.username} is loggouted")


class AbstractAdmin(ABC):
@abstractmethod
def login():
pass
@abstractmethod
def logout():
pass
@abstractmethod
def create_content():
pass
@abstractmethod
def 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?

question mark

Remember all OOP concepts:

Select the correct answer

question mark

What are magic methods?

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 5. Luku 6

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

We use cookies to make your experience better!
some-alt