YADTR (Yet Another DateTime Rant)

Roy Smith roy at panix.com
Wed Mar 26 01:58:27 CET 2014

One of my roles on this newsgroup is to periodically whine about 
stupidities in the Python datetime module.  This is one of those times.

I have some code which computes how long ago the sun set.  Being a nice 
pythonista, I'm using a timedelta to represent this value.  It would be 
difficult to imagine a less useful default way to print a timedelta:

previous sunset: -1 day, 22:25:26.295993

The idea of str() is that it's supposed to return a human-friendly 
representation of a value.  Humans do not say things like, "The sun set 
1 day ago plus 22 hours and 25 minutes".

More information about the Python-list mailing list