Store empty list in dynamic property in Python for GAE?

Unable to save empty list to dynamic property

class Mo(db.Expando) pass def newFunction mo = Mo(key_name='1') mo.list_of_stuff = [] # <--Error 

After executing the last statement, I get the error message: Unable to save empty list in dynamic property list_of_stuff

How to save empty list in dynamic property in python for google engine?

+4
source share
2 answers

You cannot, because this is an unacceptable concept. Data warehouse objects are stored as a set of key / value pairs. When you store a list of any type, it is internally represented as multiple pairs with the same key and different values, and not with the same key with a list of values.

Saving an empty list is thus equivalent to storing nothing at all. You only have null instances of this property inside your object. If you want to present an empty list, leave the unset property. If you need to distinguish between the unset property and the concept of an empty list, fill the dynamic property with another non-empty value, such as None or False .

+4
source

You cannot, you need to either define a property in your class or leave it unoccupied

+2
source

All Articles