Pythonでオブジェクトが持つプロパティをチェックする方法 hasattr関数を使う if hasattr(obj,'val') == True: print('has') else: print('not has')