Τη Παρασκευή, 22 Φεβρουαρίου 2013 8:20:20 π.μ. UTC+2, ο χρήστης rob.mar...@gmail.com έγραψε: > 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)
I'am thinking if somehting like the follwoing work: if( task and ( price and price.isdigit() and price.__len__() <= 3 ) and ( date and eval( datetime.strptime(date, '%d %m %Y').strftime('%Y-%m-%d') ) ) ): -- http://mail.python.org/mailman/listinfo/python-list