-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__call.py
48 lines (31 loc) · 906 Bytes
/
__call.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def print_text():
print('Hello')
print_text()
class Product:
def __init__(self, value_one, value_two):
self.value_one = value_one
self.value_two = value_two
def __call__(self):
return self.value_one * self.value_two
product = Product(6, 6)
print(product())
#============================================
class Product:
def __call__(self, value_one, value_two):
return value_one * value_two
product = Product()
print(product(5, 9))
def class_decorator(cls):
cls.magic_value = 40
return cls
#============================================
@class_decorator
class Product:
def __call__(self, value_one, value_two):
return value_one * self.__divide(value_two)
def __divide(self, value):
print('Test data')
return value / Product.magic_value
product = Product()
print(product(5, 9))
print(product.magic_value)