Use the isinstance() builtin function for type comparisons.