One of Python's strengths is its exhaustive library. And date and time management is an integral part of this, provided by the datetime. Logic suggests that timedelta. That is code like this would produce an error: >>> from datetime import datetime, date, time, timedelta >>> dt1 = datetime.now() >>> td1 = timedelta(hours=1 …
I'm still finding my way around the rather vast Python standard library. And today, I discovered a quick way to convert a pure time string (of format HH:MM[:SS]) into a standard datetime.time object. datetime.strptime('08:00', '%H:%M').time() That's it! A single, rather short line …
This is more for my own reference as I often forget the various steps that I followed to get an environment set up. This post lists the steps that I followed to setup an Ubuntu Server for Python/Django/MySQL environment. The steps are drawn from various resources on the …
Here's a cool bit of code snippet that I found from the web (original post here). I'm recording it here for my own easy reference without having to google it all the time. It describes a simple technique to debug Django templates using the python debugger - pdb. @register.filter def …