On Tue, Oct 2, 2012 at 6:19 PM, <aklei...@sonic.net> wrote: > > from datetime import datetime > start_date = datetime(year=2012, month=11, day=3) > print(start_date) > > datestring = '10/11/2012' > experiment_date = datetime.strftime(datestring, '%d/%m/%Y') > print(experiment_date) > > if experiment_date > start_date: > print("Experiment_date comes after start_date.") > else: > print("Expriment_date does not come after start_date.") > > Does not complete because of: > > "ImportError: _strptime not supported"
That error is surely some quirk of pythontutor.com. datetime.strftime calls time.strftime. On the other hand, datetime.strptime does import _strptime: http://hg.python.org/cpython/file/70274d53c1dd/Modules/datetimemodule.c#l3937 Did you actually use datetime.strptime? Normally you'd use strftime as method call on a datetime object: >>> from datetime import datetime >>> datestring = '10/11/2012' >>> dt = datetime.strptime(datestring, '%d/%m/%Y') >>> dt datetime.datetime(2012, 11, 10, 0, 0) >>> dt.strftime('%d/%m/%Y') '10/11/2012' _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor