Thanks to visit codestin.com Credit goes to github.com
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 2e5ea1e commit ce78460Copy full SHA for ce78460
OOP/Incapsulation
@@ -35,3 +35,27 @@ obj = Myobject()
35
#obj.__private_value = 200 # Tak k private atributu obratitsya nelzya. Nado cherez metod setter
36
obj.set_value(200)
37
print(obj.get_value()) # 200
38
+
39
40
+################################# 3) Svoistva objekta. Trebuetsya podderzhka yazyka. Bolee predpochtitelen.
41
42
+class Myobject:
43
44
+ def __init__(self):
45
+ self.__atribute = 0
46
47
+ @property
48
+ def atribute(self):
49
+ return self.__atribute
50
51
+ @atribute.setter # @atribute - takoe zhe kak i imya metoda v gettere
52
+ def atribute(self, value):
53
+ if value < 500:
54
+ self.__atribute = value
55
56
57
+obj = Myobject()
58
+print(obj.atribute) # 0
59
60
+obj.atribute = 200 # 200
61
+print(obj.atribute)
0 commit comments