Python: Python: checking the type of an object