8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e484d25 commit 958a046Copy full SHA for 958a046
section16/sample_code/4-abc-3-and-interfaces/app.py
@@ -1,5 +1,7 @@
1
from database import Database
2
from admin import Admin
3
+from user import User
4
+from saveable import Saveable
5
6
a = Admin('paco', 'perez', 2)
7
b = Admin('rolf', 'smith', 1)
@@ -9,4 +11,12 @@
9
11
10
12
user = Database.find(lambda x: x['username'] == 'paco')[0]
13
user_obj = Admin(**user)
-print(user_obj.username)
14
+print(user_obj.username)
15
+
16
+print(isinstance(user_obj, Saveable)) # This is True because it's a subclass
17
18
+# You can do things like these without worry:
19
20
+users_to_save = [a, b, User('jose', '1234')]
21
+for u in users_to_save:
22
+ u.save() # This is fine, because all users (Admin and User) implement the Saveable interface so we know they have a .save() method
0 commit comments