title: python dictionary datetime as key, keyError
body: <p>I'm trying to run a Python script using cron in Linux, which should construct a dictionary of data. I'm attempting to use <code>datetime().now().time()</code>as keys in the dictionary, but it seems to raise an error. </p>
  
  <p>Can't the <code>datetime</code> type be used as a dictionary key in Python? If that is the case, what are my alternatives?</p>
  
  <p><em>Code:</em></p>
  
  <pre><code>time_now = dt.datetime.now().time()
  date_today = dt.datetime.now().date()
  usage_dict_hourly = {}
  date_wise_dict = {}
  
  def constructing_dict(data_int):
      date_wise_dict[usage_dict_hourly[time_now]] = data_int
      print date_wise_dict
  </code></pre>
  
  <p><em>Error:</em> </p>
  
  <pre><code>&lt;ipython-input-9-ef6a500cc71b&gt; in constructing_dict(data_int)
       36 
       37 def constructing_dict(data_int):
  ---&gt; 38     date_wise_dict[usage_dict_hourly[time_now]] = data_int
       39     print date_wise_dict
       40 
  
  KeyError: datetime.time(22, 40, 33, 746509)
  </code></pre>