I know it\'s not Pythonic to write functions that care about the type of the arguments, but there are cases when it\'s simply impossible to ignore types because they are han
Since Python 3.4 the functools module now supports a @singledispatch decorator. In your case this would look like:
from functools import singledispatch
@singledispatch
def func(val):
raise NotImplementedError
@func.register
def _(val: str):
print('This is a string')
@func.register
def _(val: int):
print('This is an int')
Usage
func("test") --> "This is a string"
func(1) --> "This is an int"
func(None) --> NotImplementedError