I don\'t know how to check if a variable is primitive. In Java it\'s like this:
if var.isPrimitive():
You may want to take a look at types module, that lists all python built-in types.
types
http://docs.python.org/library/types.html