-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex0424.py
More file actions
28 lines (23 loc) · 803 Bytes
/
Copy pathex0424.py
File metadata and controls
28 lines (23 loc) · 803 Bytes
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
class Parent:
def __init__(self):
self.__private_var = "부모 값"
self._protected_var = "부모 값"
self.public_var = "부모 값"
def show_private_value(self):
print(f"__private_var: {self.__private_var}")
def show_protected_value(self):
print(f"_protected_var: {self._protected_var}")
def show_public_value(self):
print(f"public_var: {self.public_var}")
class Child(Parent):
def __init__(self):
super().__init__()
self.__private_var = "자식 값"
self._protected_var = "자식 값"
self.public_var = "자식 값"
if __name__ == "__main__":
c = Child()
c.show_private_value()
c.show_protected_value()
c.show_public_value()
print(f"c.__dict__: {c.__dict__}")