JustCaptain kod-buduschego
bb03bcdc780611e5fa808dc647b9a71eb07c292d
Перейти к файлу
Код
kod-buduschego Python 2025-20264.4. Декораторpracticeschatgpttask_9.py
anc update c70a58f 8 октября 2026 г.
task_9.py
def limit_calls(max_calls):
    count_called: int = 0
    def wraper(func):
        def called(*args, **kwargs):
            nonlocal count_called
            if count_called >= max_calls:
                raise RuntimeError
            count_called += 1
            result = func(*args, **kwargs)
            return result
        return called
    return wraper
    

@limit_calls(max_calls=2)
def hello():
    print("Hello")
    
hello()
hello()
hello()