4

What is a good way to check to see if a property is populated in an expando class (Python for App Engine)

Can I do:

if Expando_class_name.property_name_to_check:
    do = someStuff

Or is that going to give me an error?

Thanks!

Chris Dutrow
  • 45,764
  • 62
  • 180
  • 249

2 Answers2

5

Use hasattr:

if hasattr(expando_instance, 'foo'):
  # Do something with expando_instance.foo
Nick Johnson
  • 99,939
  • 16
  • 127
  • 196
2

A better way is to use the dynamic_properties method.

if 'foo' in entity.dynamic_properties():  pass
Nix
  • 54,648
  • 29
  • 144
  • 196