我尝试做以下与参数 '回归':pymongo发电机失效 - 内部发电机
def get_collection_iterator(collection_name, find={}, criteria=None):
collection = db[collection_name]
# prepare the list of values of collection
if collection is None:
logging.error('Mongo could not return the collecton - ' + collection_name)
return None
collection = collection.find(find, criteria)
for doc in collection:
yield doc
,并呼吁像:
def get_collection():
criteria = {'unique_key': 0, '_id': 0}
for document in Mongo.get_collection_iterator('contract', {}, criteria):
print document
,我看到了错误说:
File "/Users/Dev/Documents/work/dw/src/utilities/Mongo.py", line 96
yield doc
SyntaxError: 'return' with argument inside generator
我在这做什么不正确?
@MattFenwick是我没有挪亚 – daydreamer