title: strange pymongo behaviour when adding python list
body: <p>i have this code:</p>
  
  <pre><code>for product_code in product_codes:
      product_categories = []
      product_belongs_to = []
      get_categories = """SELECT * FROM stock_groups_styles_map WHERE stock_groups_styles_map.style ='%s'""" % (product_code,)
      for category in sql_query(get_categories):
  
          if {product_code: category[1]} in product_categories:
              pass
          else:
              product_categories.append({product_code: category[1]})
  
      for category in product_categories:
          category_group = get_group(category.values()[0])
          if category_group:
              category_name = category_group.replace("-", " ").title()
              if category_name:
                  if category_name == "Vests":
                      product_belongs_to.append(get_category_ids("Tanks"))
                  else:
                      cat_value = get_category_ids(category_name)
                      if cat_value:
                          cat_id = get_category_ids(category_name)
                          product_belongs_to.append(cat_id[0])
  
  
  ccc_products = {
      '_id': ObjectId(),
      'collectionId': collectionId,
      'categoryIds': product_belongs_to,
      'visible' : 'true',
      }
  products.save(ccc_products)
  </code></pre>
  
  <p>when i look at the mongdb collection, i have:</p>
  
  <pre><code>{
      "_id" : ObjectId("53aaa4e1d901f2430f25a6ba"),
      "collectionId" : ObjectId("53aaa4d6d901f2430f25a604"),
      "visible" : "true",
      "categoryIds" : [
          ObjectId("53aaa4d6d901f2430f25a5fc"),
          ObjectId("53aaa4d3d901f2430f25a5f9")
      ]
  }
  </code></pre>
  
  <p>this is correct, but if i only have one item in the <code>product_belongs_to</code> list, i get:</p>
  
  <pre><code>{
      "_id" : ObjectId("53aaa4e1d901f2430f25a6bd"),
      "collectionId" : ObjectId("53aaa4d6d901f2430f25a604"),
      "visible" : "true",
      "categoryIds" : [
          [
              ObjectId("53aaa4d6d901f2430f25a5fe")
          ]
      ]
  
  }
  </code></pre>
  
  <p>basically, <code>"categoryIds"</code> is an <code>array</code> containing an <code>array</code></p>
  
  <p>the only way to fix this is to do the following:</p>
  
  <pre><code>if len(product_belongs_to) == 1:
      product_belongs_to = product_belongs_to[0]
  </code></pre>
  
  <p>what am i missing?</p>
  
  <p>any advice much appreciated.</p>