The datetime function: strptime() DOES check the date for validity. So try 
something like:

from datetime import datetime

def get_date():
  while True:
    try:
      date_in = raw_input("Enter date (dd mm yyyy): ")
      date_out = datetime.strptime(date_in,"%d %m %Y").strftime("%Y-%m-%d")
      return date_out
    except ValueError:
      print "Invalid date: {}, try again...".format(date_in)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to