-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path21_SimpleClass.py
More file actions
47 lines (36 loc) · 944 Bytes
/
21_SimpleClass.py
File metadata and controls
47 lines (36 loc) · 944 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class Class1:
def __init__(self,a,b):
self.a = a
self.b = b
print("Estou no construtor!")
#decorators: https://www.programiz.com/python-programming/decorator
@property
def a(self):
#print("Get a")
return self.__a
@a.setter
def a(self,a):
#print("Set a")
self.__a = a
def __str__(self):
#return self.a
return "string da class 1 com a = " + str(self.a) + " , b= " + str(self.b)
def __repr__(self):
return "[" + str(self.a) + "," + str(self.b) + "]"
@staticmethod
def metodo_estatico(a,b):
return a + b
def main():
l = Class1(10,20)
#l.b = 3
print(str(l))
print([l,l,l])
#print(l.a)
#l.a = 5
#print(l)
#print([l])
print("Metodo estatico = " + str(Class1.metodo_estatico(2,3)))
print(type(l))
print(isinstance(l, str))
if __name__ == "__main__":
main()