JustCaptain kod-buduschego
llm/change-52ed52
Перейти к файлу
Код
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()