'datetime.datetime' object is not subscriptable
<p>I've checked every other post about this, but none can fix my issue.</p>

<p>I made a list that holds tuples with an id and a datetime object. Everytime I try to clean up the list with:
<code>last_encounters = [item for item in last_encounters if item[1] &lt; datetime.utcnow]</code>
I get the error that <code>'datetime.datetime' object is not subscriptable</code>. It's getting pretty annoying, I tried dicts.. didn't work.</p>

<p>Also tested the item[1], according to my print it is a datetime.</p>

<p>Even tried changing it to <code>(x,y) for x,y in last_encounters if y &lt; ...</code> also did NOT work.</p>

<p>Some useful code:</p>

<pre><code>list = []
d_t = datetime.utcfromtimestamp(9000000)     
list += [('lel', d_t)]     
list = [item for item in list if item[1] &lt; datetime.utcnow]
</code></pre>

<p>I hope someone can tell me what I am doing wrong here.</p>

<p>Thanks in advance,</p>

<p>Kevin</p>

<p>Try calling <code>utcnow</code> as a method <code>utcnow()</code>:</p>

<pre><code>last_encounters = [item for item in last_encounters if item[1] &lt; datetime.utcnow()]
</code></pre>

<p>I couldn't reproduce your error with a version of your code, but a version with items in the list lead to this fix.</p>

python python-2.7 datetime tuples