Monday, January 28, 2008

python valentine - a program for your day

I couldn't help but follow up with another unValentine card. The novel part about this card is that it can apply to anyone on Valentine's Day -- single, dating, married, whatever. It's written in Python, thanks to some help from Chris Slowe who made it not look like some crappy Pascal that never would have compiled.

The Python Valentine is perfect for any and all geeks in your life, except for Java programmers. Oh, and half the profits of all unHoliday Cards still go to fight pediatric cancer -- bonus feel-good feeling!

#!/usr/bin/env python

from relationships import *
from alcohol import shot, beer

def valentines_day(self):
if == 0: = False
elif self.num_prev_dates == 0: -= dinner() -= pointless_gift()
else: -= dinner()/sqrt(self.num_prev_dates)
if randInt(self.num_prev_dates): -= pointless_gift()/self.num_prev_dates
elif self.married:
if self.years_married < 5: -= dinner()/(self.years_married ** 2)
while self.blood_alcohol < .08:
self.blood_alcohol += beer()
while self.blood_alcohol < .22:
self.blood_alcohol += shot()
Paul Graham is still giving us hell for not writing it in Lisp.