title: How to access fields of a query
body: <p>I have a query that from this code </p>
  
  <pre><code>cursor = db.MCAddrPortPairs.find({'Symbol' : symbol})[:1]
  print str(json.dumps({'results': list(cursor)},
                          default = bson.json_util.default,
                          indent = 4))
  </code></pre>
  
  <p>returns the following doc:</p>
  
  <pre><code>{
      "results": [
          {
              "MCPort": 345, 
              "Symbol": "EUR/USD", 
              "_id": {
                  "$oid": "56fc34e961fed32064e656b0"
              }, 
              "MCAddr": "239.0.0.222"
          }
      ]
  }
  </code></pre>
  
  <p>MCAddr is a string and MCPort is an int. How do I access the fields MCAddr and MCPort in python?</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>If I say</p>
  
  <pre><code>doc = db.MCAddrPortPairs.find({'Symbol' : symbol})[:1]
  
  symbolMCIPAddrStr = doc["MCAddr"]
  symbolMCPort = doc["MCPort"]
  </code></pre>
  
  <p>I get error:</p>
  
  <pre><code>File "mc.py", line 44, in initializeMongo
      symbolMCIPAddrStr = doc["MCAddr"]
    File "/home/idf/anaconda/lib/python2.7/site-packages/pymongo/cursor.py", line 531, in __getitem__
      self.__check_okay_to_chain()
    File "/home/idf/anaconda/lib/python2.7/site-packages/pymongo/cursor.py", line 342, in __check_okay_to_chain
      raise InvalidOperation("cannot set options after executing query")
  pymongo.errors.InvalidOperation: cannot set options after executing query
  </code></pre>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>If instead I say</p>
  
  <pre><code>doc = db.MCAddrPortPairs.find_one({'Symbol' : symbol})[:1]
  
  
  Traceback (most recent call last):
    File "mc.py", line 86, in &lt;module&gt;
      main()
    File "mc.py", line 63, in main
      initializeMongo("EUR/USD") 
    File "mc.py", line 39, in initializeMongo
      doc = db.MCAddrPortPairs.find_one({'Symbol' : symbol})[:1]
  TypeError: unhashable type
  </code></pre>