I was browsing the Python 2.6 docs and saw the ‘datetime’ library. On a lark, I rewrote my old C-coded ’days’ app as Python:
1234567891011121314
#!/usr/bin/env python# Rewrite of days-old calculator using Python. Gotta love this language!# pfh 2/12/09importdatetimebd=datetime.date(year=1968,month=2,day=2)today=datetime.date.today()tdiff=today-bdprint("\nToday is %s and you are %s days old.\n" \
%(today.strftime("%A, %B %d %Y"),tdiff.days))
Took me all of ten minutes, and the code is shorter, easy to tweak and such. Damn, I’m liking Python.