Python 应用程序引擎-检查Expando类中是否存在属性

Python 应用程序引擎-检查Expando类中是否存在属性,python,google-app-engine,expando,Python,Google App Engine,Expando,检查expando类(Python for App Engine)中是否填充了属性的好方法是什么 我可以做: if Expando_class_name.property_name_to_check: do = someStuff 还是这会给我一个错误 谢谢 使用hasattr: if hasattr(expando_instance, 'foo'): # Do something with expando_instance.foo 更好的方法是使用dynamic_propert

检查expando类(Python for App Engine)中是否填充了属性的好方法是什么

我可以做:

if Expando_class_name.property_name_to_check:
    do = someStuff
还是这会给我一个错误


谢谢

使用hasattr:

if hasattr(expando_instance, 'foo'):
  # Do something with expando_instance.foo

更好的方法是使用dynamic_properties方法

if 'foo' in entity.dynamic_properties():  pass