pymongo and attribute dictionaries
Rob Gaddi
rgaddi at technologyhighland.invalid
Wed Feb 4 16:28:43 EST 2015
On Wed, 04 Feb 2015 13:54:22 -0700, Ian Kelly wrote:
> I'd prefer map (or itertools.imap in Python 2) over the inline generator
> in this case:
>
> for doc in map(Doc, client.db.radios.find({’_id': {’$regex’:
> ‘^[ABC]'}})):
> pprint(doc)
>
> Or if you like, a utility function wrapping the same.
>
> def docs(dicts):
> return map(Doc, dicts)
Or, if you really wanted to be crazy
for d in client.db.radios.find({’_id': {’$regex’: ‘^[ABC]'}}):
doc = Doc(d)
pprint(doc)
I mean, I realize linefeeds don't grow on trees and all...
--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order. See above to fix.
More information about the Python-list
mailing list