Advertisement
Fhernd

desenvolver-funcion.py

Feb 6th, 2018
871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. from functools import wraps
  2.  
  3. def funcion_decoradora(fn):
  4.     mensaje = fn.__qualname__
  5.    
  6.     @wraps(fn)
  7.     def envoltura(*args, **kwargs):
  8.         print(mensaje)
  9.        
  10.         return fn(*args, **kwargs)
  11.        
  12.     return envoltura
  13.    
  14.  
  15. @funcion_decoradora
  16. def sumar(x, y):
  17.     return x + y
  18.    
  19. print(sumar(5, 3))
  20. print()
  21. print(sumar.__wrapped__(5, 3))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement