Pythonic way of ensuring that input argument to a function is int/str?
Basically the argument that foo() expects should be passed as int, but there is a possibility that someone will pass it as str (which is also valid if str can be converted to int). This is what I came up with:
func_name = 'foo'
if type(input_argument) is not int or type(input_argument) is not str:
'%s: "input_argument" expects int/str, not %s' % (
'%s: "input_argument" expects number in str/int format' % func_name
Is there something that is built-in which could simplify this in a more pythonic way?