[python] What's the canonical way to check for type in Python?