Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User:
- def __init__(self, username, email):
- self.username = username
- self.email = email
- def get_info(self):
- return f"Użytkownik {self.username}, email {self.email}"
- class Admin(User):
- def __init__(self, username, email, permissions):
- self.permissions = permissions
- super().__init__(username, email)
- def get_info(self):
- message = super().get_info()
- for permission in self.permissions:
- message +=f'Uprawnienia do {permission}'
- return message
- def ban_user(self, user: User):
- print(f"Banuje użytkownika {user.email}")
- class SuperAdmin(Admin):
- pass
- user = User("kacper", "[email protected]")
- print(isinstance(user, Admin))
- print(isinstance(user, User))
- print(user.get_info())
- print("-" * 30)
- admin = Admin("admin", "[email protected]", ['manage.users'])
- print(admin.username)
- print(admin.email)
- print(admin.get_info())
- print(isinstance(admin, Admin))
- print(isinstance(admin, User))
- admin.ban_user(user)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement