title: Python MongoDB Aggregate error
body: <p>This code gives me an error:</p>
  
  <p>TypeError: 'CommandCursor' object has no attribute '<strong>getitem</strong>'</p>
  
  <p>However when my friend runs the same code on her computer, she doesn't get an error. I'm using an Intel Pentium CPU on Windows. I have MongoDB running (version 3.4), Python 2.7.13 :: Anaconda 4.3.1 (64-bit). </p>
  
  <pre><code>import json
  import pymongo 
  from bson import json_util
  import re
  
  FROM = "kenneth.lay@enron.com"
  
  client = pymongo.MongoClient()
  db = client.enron    
  mbox = db.mbox
  
  //Get the recipient lists for each message
  
  recipients_per_message = db.mbox.aggregate([
  {"$match" : {"From" : re.compile(r".*{0}.*".format(FROM), re.IGNORECASE)}}, 
  {"$project" : {"From" : 1, "To" : 1} }, 
  {"$group" : {"_id" : "$From", "recipients" : {"$addToSet" : "$To" } } }                    
  ])['result'][0]['recipients']
  
  //The exact Error was:
  TypeError Traceback (most recent call last) 
  19 {"$project" : {"From" : 1, "To" : 1} },   
  20 {"$group" : {"_id" : "$From", "recipients" : {"$addToSet":"$To" }}}  
  ---&gt; 21 ])['result'][0]['recipients'] 
  TypeError: 'CommandCursor' object has no attribute 'getitem'
  </code></pre>