0

I am able to store a collections.Counter into the app engine data store, however when I retrieve it and try to parse it, I get the following error:

for word in counter:
TypeError: 'NoneType' object is not iterable

If I just print the output, it shows:

Counter({'a': 25, 'b': 12, 'c': 10, 'd': 9})

Now if I initialize a dictionary with the same values, I store it the same way as the counter, I can retrieve it and parse it without any problem:

counter = Counter()
counter = {'a': 25, 'b': 12, 'c': 10, 'd': 9};
...
#Store in app engine datastore and retrieve as "values"
...
for letter in values:
    self.response.write(letter + ":" + str(values[letter]) + "<br>")

Output: a:25 c:10 b:12 d:9

Does this mean you cannot store a Counter but should better transform as a Dictionary before storing it?

Thanks

4

0 回答 0