Advertisement
Alaricy

спринт 4 декораторы 2/2

Feb 26th, 2022
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. def cache3(func):
  3.     count = {'count':0}
  4.     cash = {}
  5.     def wrapper(*args, **kwargs):
  6.         ttt = count['count']
  7.         if count['count'] == 2:
  8.             count['count'] = 0
  9.             cash.clear()
  10.         else:
  11.             #print(f'итерация{ttt}')
  12.             count['count'] += 1            
  13.         if args not in cash:
  14.             cash[args] = func(*args, **kwargs)
  15.         return cash[args]
  16.     return wrapper
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement