Posts by Peter Bengtsson

Knowing what you want can make a huge difference (…with pymongo)

So I’ve got a piece of MongoKit code that simply wraps a pymongo query and it looks like this times = defaultdict(list) for pq in (db.PlayedQuestion.collection .find({'play.$id': {'$in': play_ids}})): if pq['time'] is not None: if pq['right']: times['right'].append(pq['time']) elif pq['answer']: times['wrong'].append(pq['time']) What I noticed was … Continue reading