Advertisement
danya11334

Untitled

Feb 20th, 2025
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import sys
  2. import functools
  3.  
  4. def takes(*types):
  5.     def decorator(func):
  6.         @functools.wraps(func)
  7.         def wrapper(*args):
  8.             for i, (arg, expected_type) in enumerate(zip(args, types)):
  9.                 if not isinstance(arg, expected_type):
  10.                     raise TypeError(f"Argument {i+1} has wrong type: expected {expected_type}, got {type(arg)}")
  11.             return func(*args)
  12.         return wrapper
  13.     return decorator
  14.  
  15. exec(sys.stdin.read())
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement