diff --git a/Roadmap/24 - DECORADORES/python/cyberdidac.py b/Roadmap/24 - DECORADORES/python/cyberdidac.py new file mode 100644 index 0000000000..c5288a0180 --- /dev/null +++ b/Roadmap/24 - DECORADORES/python/cyberdidac.py @@ -0,0 +1,22 @@ +def count_calls(func): + def wrapper(): + wrapper.count += 1 + print(f"La funciĆ³n {func.__name__} ha sido llamada {wrapper.count} veces") + return func() + + wrapper.count = 0 + return wrapper + + +@count_calls +def say_hello(): + print("Hola!") + + +def main(): + say_hello() + say_hello() + + +if __name__ == '__main__': + main()