why not datetime.strptime() ?

Skip Montanaro skip at pobox.com
Fri Jan 7 14:32:03 EST 2005

    josh> Shouldn't datetime have strptime?

Sure, but it's not quite as trivial to implement as was strftime() support.
While strftime() is a C library function and thus easily called from within
the datetime C code, strptime() is implemented in Python as part of the time
module for portability (strptime(3) is not universally available).  You'd
need to import the time module, call its strptime() function with the input
string and format, then use the tuple it returns to initialize a new
datetime object.

If someone wants to get their feet wet with extension module programming
this might be a good place to start.  Mostly, I think nobody who has
needed/wanted it so far has the round tuits available to spend on the task.


More information about the Python-list mailing list