2011-12-13 3 views
0

J'ai un code simple:Comment simplifier ce code?

results = mongo.group(                    
     key = [ 'test','id' ], 
     .... 
    ) 
    temp_hash = {} 
    for result in results: 
     if temp_hash.has_key(result['test']): 
      temp_hash[result['test']] = int(temp_hash[result['test']]) + 1 
     else: 
      temp_hash[result['test']] = 1 

Comment simplifier ce code en utilisant la logique seulement MongoDB?

Répondre