Category Archives: python

Tornado

I’m starting to use tornado as my go-to framework for python web projects. After being a django user for 5+ years this is a pretty big  change for me. I like that it’s simple and gets in your way as little as possible. There’s something nice to be able to run a whole web application in [...]

Also posted in Uncategorized | Leave a comment

Easy Handling of Python datetimes in JSON.

Passing date objects between Python and Javascript can be difficult. I started using this as a workaround to handle python’s datetime objects, but it should work for any non-standard, non-primitive python type: import time, math def dt_handler(obj): if isinstance(obj, datetime) or isinstance(obj, date): v = math.floor(time.mktime(obj.timetuple())) return "DATE(%d)" % v else: return repr(obj) Instead of [...]

Posted in python | Leave a comment