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

问题描述

| 什么是检查属性是否已在expando类中填充的好方法(适用于Python的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