title: How can I get hours from a Python datetime?
body: <p>I have a Python datetime, d, and I want to get the number of hours since midnight as a floating point number.  The best I've come up with is:</p>
  
  <pre><code>h = ((((d.hour * 60) + d.minute) * 60) + d.second) / (60.0 * 60)
  </code></pre>
  
  <p>Which gives 4.5 for 4:30am, 18.75 for 6:45pm, etc.  Is there a better way?</p>