how to know if a variable is a tuple, a string or an integer?

isinstance(obj, tuple)
isinstance(obj, basestring)
isinstance(obj, int)

You just use:

type(varname)

which will output int, str, float, etc...


make use of isinstance ?

if isinstance(var, int):

if isinstance(var, str):

if isinstance(var, tuple):

Please note, should you wanted to check your var type in if statement, the construct if type(varname) == "tuple": won't work. But these will:

if type(varname) is tuple:
if type(varname) is list:
if type(varname) is dict:
if type(varname) is int:
if type(varname) is str: