parsing a date

Kalle Anke skromta at gmail.com
Sat Sep 24 03:13:22 EDT 2005


On Fri, 23 Sep 2005 23:01:18 +0200, Larry Bates wrote
(in article <htadnfhhQL628KneRVn-gw at comcast.com>):

> but I'm not sure it is "better".  I guess it depends
> on what you want to do with them after parsing.


Sorry, I should have been clearer. I want to parse the date and create a 
'date object' that is a part of larger object (I'm parsing a text file that 
represents the larger object and the date is a part of it).

So my question should probably be: is there a better way to parse the date 
and generate the 'date object' than the two step 

 w = strptime(d,'%Y-%m-%d')
 datetime.date( w[0], w[1], w[2] )

Since I'm new to many things in Python I'm trying to learn if there is a 
"better" way of doing things.

                    jem




More information about the Python-list mailing list