title: Python - Why does this list comprehension return an empty list?
body: <p>I have a list of tasks, and I'm trying to select all tasks with a given id.</p>
  
  <pre><code># temp global tasks list
  tasks = [
      {
          'id': 1,
          'title': u'Buy groceries',
          'description': u'Milk, Cheese, Pizza, Fruit, Tylenol',
          'done': False
      },
      {
          'id': 2,
          'title': u'Learn Python',
          'description': u'Need to find a good Python tutorial on the web',
          'done': False
      }
  ]
  
  # here I try to select some tasks. 'request.args.get('id')' is 2 in my test
  selectedTasks = tasks
  
  if 'id' in request.args:
      selectedTasks = [task for task in selectedTasks if task['id'] == request.args.get('id')]
  </code></pre>
  
  <p>If I run this, <code>selectedTasks</code> is empty. However I don't see why.</p>
  
  <p>I tried printing some values:</p>
  
  <pre><code># just before the list comprehension
  print(selectedTasks, file=sys.stderr)
  print(request.args.get('id'), file=sys.stderr)
  print(selectedTasks[1]['id'], file=sys.stderr)
  </code></pre>
  
  <p>This prints:</p>
  
  <pre><code>[{'id': 1, 'title': 'Buy groceries', 'description': 'Milk, Cheese, Pizza, Fruit, Tylenol', 'done': False}, {'id': 2, 'title': 'Learn Python', 'description': 'Need to find a good Python tutorial on the web', 'done': False}]
  2
  2
  </code></pre>
  
  <p>So the tasks are all there, <code>request.args.get('id')</code> is correct, and the second task has id <code>2</code>. So why doesn't this work?</p>