Nice job! Here's a nitpicky critique -- take it as a compliment to your obvious talent at picking up a language in short order.
Am I correct in thinking that your background is in C?
(1) no '\' is needed after ','. Python accepts a comma as a line continuation character.
(2) the function to_upper() is correct, but also unnecessary. Python strings have a built-in method .upper() that does exactly the same (but faster, being in C).
(3) In general, modules should be imported at the top of the program.
(4) The error-checking can be done more concisely (and correctly -- you don't catch non-integer inputs) like this:
while True:
try:
year = int(raw_input("What year were you born? "))
except:
print "enter an integer, please!"
continue
if year < 0:
print "Impossible! You weren't born BC!"
elif year > now.year: # << Note dynamic checking!
print "Impossible! You aren't born in the future!"
else:
break
(5) the month-getting code should be shoved into a function for clarity. And, it can take advantage of Python's advanced structures:
def get_month():
months = ["JAN","FEB","MAR",etc.]
while True:
month = raw_input("What month were you born? ")
month = month[:3].upper()
if month in months:
return months.index(month) + 1
else:
try:
month = int(month)
if 0 < month < 13:
return month
else:
print "invalid month!"
continue
except:
print "invalid month!"
This takes the place of the long if ... elif chain.
(6) Python really does include all the batteries. The datetime module can do all of this in one fell swoop:
def extract_date(s):
try:
date = datetime.datetime.strptime(s, "%d %m %Y")
except:
try:
date = datetime.datetime.strptime(s, "%d %b %Y")
except:
return None
return date
while True:
year = raw_input("What year were you born? ")
month = raw_input("What month were you born? ")
day = raw_input("What day were you born? ")
bday = extract_date(day + " " + month[:3].title() + " "+ year)
if bday == None:
print "Illegal info!"
continue
else:
break
Again, take all of these as incentive to keep learning; your original code is good.
Jeff