-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp4.py
50 lines (44 loc) · 1.12 KB
/
app4.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
48
49
50
'''fichero = open("prueba.txt",'w')
print(fichero.write("Lopez"))
print(fichero.readline())'''
'''def mi_decorador(arg):
def decorador(funcion):
def nueva(a,b):
value = funcion(a,b)
print(f"{arg} {value}")
return nueva
return decorador
@mi_decorador("La suma es: ")
def suma(a,b):
return a+b'''
def log(fichero, arg):
def decorador(funcion):
def nueva(a,b):
with open(fichero,'a') as openedfile:
value = funcion(a,b)
openedfile.write(f"{arg} {value}\n")
return nueva
return decorador
@log('ficherosalida.log',"La suma es: ")
def suma(a,b):
return a+b
def operaciones(op):
def multi(a,b):
return a * b
def divi(a,b):
return a // b
def restar(a,b):
return a - b
def sumar(a,b):
return a + b
if op == "multi":
return multi
if op == "divi":
return divi
if op == "resta":
return restar
if op == "suma":
return sumar
suma(4,5)
#funcion = operaciones("divi")
#print(funcion(10,2))