Use type(obj) instead of obj.__class__