-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeYad2.py
More file actions
87 lines (66 loc) · 1.68 KB
/
CodeYad2.py
File metadata and controls
87 lines (66 loc) · 1.68 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
'''
/// CodeYad31(self)--function to review the Python language by CodeYad.com
/// function decorator
/// Contains CodeYad lessons by video: 114 and https://www.geeksforgeeks.org/decorators-in-python/
/// ADDED by engineer B.Pourtavakoli on 1403/09/01
'''
import os
######################################################
def hello(strName = "Behdad"):
def hello_behdad():
print(f"Hi {strName}, You are the Best.")
return (hello_behdad)
def hello_decorator(func):
# wrapper
def inner():
print("Hi, this is before function execution.")
func()
print("this is after function execution.")
return (inner)
def normal_hello():
print("Hi Behdad.")
######################################################
@hello_decorator
def normal_hello2():
print("Hi Behdad.")
######################################################
@hello_decorator
def normal_hello3(strMessage):
return (f"{strMessage}")
######################################################
def decor1(func):
def inner():
x = func()
return (x * x)
return (inner)
def decor(func):
def inner():
x = func()
return (2 * x)
return (inner)
@decor1
@decor
def num():
return (10)
@decor
@decor1
def num2():
return (10)
# print(num())
# print()
# print(num2())
######################################################
if (os.name == "nt"):
_ = os.system("cls")
print("Test1: ")
newFunc = hello()
newFunc()
print()
print("Test2: ")
newFunc = hello_decorator(normal_hello)
newFunc()
print()
print("Test3: ")
normal_hello2()
# print()
# normal_hello3("Fuck you asshole!") ## It has error / Es liegt ein Fehler vor. {Es hat ein Fehler.}