I don\'t know how to check if a variable is primitive. In Java it\'s like this:
if var.isPrimitive():
If it helps,
In [1]: type(1) Out[1]: In [2]: type('a') Out[2]: In [3]: (type(5.4) Out[3]: In [5]: type(object) Out[5]: In [8]: type(int) Out[8]: