PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from collections import UserList # To inherit Userlist.data, essentially a customizable list.
class Guest():
def __init__(self, name):
self.name = name
def __str__(self):
return f"🥲 Hi, I'm {self.name}. I'm a happy guest."
# iterable class. this guest_list can only grow...
class OneWayGuestBook(UserList):
def __init__(self, *guests):
super().__init__(Guest(g) for g in guests)
def read(self):
return tuple(self.data)
# make it immutable outside the class,
# because we can...
class HotelCalifornia(UserList):
def __init__(self, name, *guests):
self._name = name
self._guestbook = OneWayGuestBook(*guests)
@property
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run