呼び出しごとにアイテムを生成するジェネレーター関数を作成しようとしていますが、同じアイテムを取得し続けます。これが私のコードです:
1 from pymongo import Connection
2
3 connection = Connection()
4 db = connection.store
5 collection = db.products
6
7 def test():
8 global collection #using a global variable just for the test.
9 items = collection.find()
10 for item in items:
11 yield item['description']
12 return