Travis Griggs wrote:
for doc in client.db.radios.find({’_id': {’$regex’: ‘^[ABC]'}}): pprint(doc)
changes to
for doc in ((Doc(d) for d in client.db.radios.find({’_id': {’$regex’:
‘^[ABC]'}})): pprint(doc)
Are there other approaches? Feel free to impress me with evil abuses in the
interest of academic enrichment...
You could encapsulate some of that in a helper function such as
def docs(source):
for d in source:
yield Doc(d)
then your example becomes
for doc in docs(client.db.radios.find({’_id': {’$regex’: ‘^[ABC]'}})):
pprint(doc)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list