title: How to fix issue with 'datetime.datetime' which has no attribute timedelta?
body: <p>How will I fix this problem on Python. Here's my code:</p>
  <pre><code>    import time
      import datetime
      from time import mktime
      from datetime import datetime
  
      date = '20120814174530'
      date_to_strp = time.strptime(date, '%Y%m%d%H%M%S') #convert the value of date into strptime
      date_final = datetime.fromtimestamp(mktime(date_to_strp))
      #convert date_to_strp so so i can use it to subtract a value from a timedelta later
  
      date_substracted = date_final - datetime.timedelta(hours = 36)
  </code></pre>
  <p>this has an error:</p>
  <blockquote>
  <p>type object 'datetime.datetime' has no attribute 'timedelta'</p>
  </blockquote>
  <p>even though I <code>import datetime</code>, I think it was overriden by <code>from datetime import datetime</code>, but when I changed the position of <code>import datetime</code> and <code>from datetime import datetime</code>, the error is:</p>
  <blockquote>
  <p>'module' object has no attribute 'fromtimestamp'</p>
  </blockquote>
  <p>I can fix this both error with this code:</p>
  <pre><code>    import time
      from time import mktime
      from datetime import datetime
  
      date = '20120814174530'
      date_to_strp = time.strptime(date, '%Y%m%d%H%M%S')
      date_final = datetime.fromtimestamp(mktime(date_to_strp))
  
      import datetime
  
      date_substracted = date_final - datetime.timedelta(hours = 36)
  </code></pre>
  <p>Now, with this code it is functioning properly, but what I want is that all import part would be at the top as a good practice, any suggestion on how will i do that without any error with this situation or any suggestion on how will i code it in other way around.</p>