Comparing dates in Python
<p>Here's a little snippet that I'm trying execute:</p>

<pre><code>&gt;&gt;&gt; from datetime import *
&gt;&gt;&gt; item_date = datetime.strptime('7/16/10', "%m/%d/%y")
&gt;&gt;&gt; from_date = date.today()-timedelta(days=3)
&gt;&gt;&gt; print type(item_date)
&lt;type 'datetime.datetime'&gt;
&gt;&gt;&gt; print type(from_date)
&lt;type 'datetime.date'&gt;
&gt;&gt;&gt; if item_date &gt; from_date:
...     print 'item is newer'
...
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
TypeError: can't compare datetime.datetime to datetime.date
</code></pre>

<p>I can't seem to compare the date and the datetime values. What would be the best way to compare these? Should I convert the datetime to date or vice-versa? How do i convert between them.</p>

<p>(A small question but it seems to be a little confusing.)</p>

<p>Thanks.</p>
