Advertisement
ksieradzinski

Untitled

Mar 19th, 2025
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. class User:
  2. def __init__(self, username, email):
  3. self.username = username
  4. self.email = email
  5.  
  6. def get_info(self):
  7. return f"Użytkownik {self.username}, email {self.email}"
  8.  
  9. class Admin(User):
  10. def __init__(self, username, email, permissions):
  11. self.permissions = permissions
  12. super().__init__(username, email)
  13.  
  14. def get_info(self):
  15. message = super().get_info()
  16. for permission in self.permissions:
  17. message +=f'Uprawnienia do {permission}'
  18.  
  19. return message
  20.  
  21. def ban_user(self, user: User):
  22. print(f"Banuje użytkownika {user.email}")
  23.  
  24.  
  25. class SuperAdmin(Admin):
  26. pass
  27.  
  28. user = User("kacper", "[email protected]")
  29. print(isinstance(user, Admin))
  30. print(isinstance(user, User))
  31. print(user.get_info())
  32. print("-" * 30)
  33.  
  34. admin = Admin("admin", "[email protected]", ['manage.users'])
  35. print(admin.username)
  36. print(admin.email)
  37. print(admin.get_info())
  38. print(isinstance(admin, Admin))
  39. print(isinstance(admin, User))
  40.  
  41. admin.ban_user(user)
  42.  
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement