Re: Need Help comparing dates
- From: Tim Chase <python.list@xxxxxxxxxxxxxxxxx>
- Date: Mon, 19 Jun 2006 13:39:24 -0500
I kept getting a Python error for the following line:
month = m[webMonth]
I changed it to month = month_numbers[webMonth]
and that did the trick.
Sorry for the confusion. Often when I'm testing these things, I'll be lazy and create an alias to save me the typing. In this case, I had aliased the month_numbers mapping to "m":
>>> m = month_numbers
and it slipped into my pasted answer email. You correctly fixed the problem. The purpose of the mapping is simply to resolve the month name to the month number so that the month number can be used. Depending on how predictable the website's date string will be, you can use
month_numbers = dict([(date(2006, m, 1).strftime("%b").upper(), m) for m in range(1,13)])
and then use
month = month_numbers[webMonth.upper()]
or
month = month_numbers[webMonth[0:3].upper()]
depending on whether the website might return full month names or not.
-tkc
.
- Follow-Ups:
- Re: Need Help comparing dates
- From: colincolehour
- Re: Need Help comparing dates
- References:
- Need Help comparing dates
- From: colincolehour
- Re: Need Help comparing dates
- From: Tim Chase
- Re: Need Help comparing dates
- From: colincolehour
- Need Help comparing dates
- Prev by Date: Re: copyfile avoiding overwrites and race conditions
- Next by Date: Overriding a function...
- Previous by thread: Re: Need Help comparing dates
- Next by thread: Re: Need Help comparing dates
- Index(es):
Relevant Pages
|