One of the new features in python3.5 is type hinting. For example the code below is valid now:
def greeting(name: str) -> str: return \'Hello \' + nam
I think the simplest way is to check the type:
def greeting(name): if not isintstance(name, str): raise TypeError('Expected str; got %s' % type(name).__name__) return 'Hello ' + name