I would like to define some generic decorators to check arguments before calling some functions.
Something like:
@checkArguments(types = [\'int\', \'
I think the Python 3.5 answer to this question is beartype. As explained in this post it comes with handy features. Your code would then look like this
from beartype import beartype
@beartype
def sprint(s: str) -> None:
print(s)
and results in
>>> sprint("s")
s
>>> sprint(3)
Traceback (most recent call last):
File "", line 1, in
File "", line 13, in func_beartyped
TypeError: sprint() parameter s=3 not of