title: Check if time is between tonight and tomorrow morning
body: <p>The following condition does not work, any idea? Does Python think that 8am belongs to the same day and so this condition is not possible?</p>
  
  <pre><code>from datetime import datetime, time
  now = datetime.now()
  now_time = now.time()
  if now_time &gt;= time(23,00) and now_time &lt;= time(8,00): 
      try:
          print 'hall light turning on'
      except:
          print 'Could not connect to Hue gateway'
  </code></pre>