Pregunta de entrevista de System1

Create a Python function decorator to check the type of a function argument.

Respuesta de la entrevista

Anónimo

13 jun 2018

def check_type(typ): def check(func): def wrapper(arg): assert isinstance(arg, typ) return func(arg) return wrapper return check