Re: Calculate an age

2007-12-17 Thread StephenRFerg
You might want to look at pyfdate: http://www.ferg.org/pyfdate

This Python program:
==
from pyfdate import *
birthday = Time(2000,2,29)

today = Time(2003,2,28)
years, months, period = today.diffym(birthday)
print "On", today.d
print "person is", years, "years", months,"months", period.shortest

today = Time(2003,3,1)
years, months, period = today.diffym(birthday)
print "On", today.d
print "person is", years, "years", months,"months", period.shortest
==

produces this output
==
On February 28, 2003
person is 3 years 0 months
On March 1, 2003
person is 3 years 0 months 1 day
==

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bizarre behavior with mutable default arguments

2007-12-30 Thread StephenRFerg
This is a well-known python gotcha.  See:
http://www.ferg.org/projects/python_gotchas.html#contents_item_6
-- 
http://mail.python.org/mailman/listinfo/python-list