B
Bill
Hello --
I'm parsing the output of the finger command, and was wondering
something...If I'm given a month abbrievation (such as "Jan"), what's
the best way to figure out the month number? I see that there's
something called "month_abbr" in the calendar module. However, when I
try to do calendar.month_abbr.index("Jan"), I get "_localized_month
instance has no attribute 'index'." So it seems that month_abbr isn't
a regular list. I'm currently doing it this way:
def month_number(monthabbr):
"""Return the month number for monthabbr; e.g. "Jan" -> 1."""
for index, day in enumerate(calendar.month_abbr):
if day == monthabbr:
return index
which works well enough but isn't very clever. I'm pretty new to
Python; what am I missing here?
Thanks -- Bill.
I'm parsing the output of the finger command, and was wondering
something...If I'm given a month abbrievation (such as "Jan"), what's
the best way to figure out the month number? I see that there's
something called "month_abbr" in the calendar module. However, when I
try to do calendar.month_abbr.index("Jan"), I get "_localized_month
instance has no attribute 'index'." So it seems that month_abbr isn't
a regular list. I'm currently doing it this way:
def month_number(monthabbr):
"""Return the month number for monthabbr; e.g. "Jan" -> 1."""
for index, day in enumerate(calendar.month_abbr):
if day == monthabbr:
return index
which works well enough but isn't very clever. I'm pretty new to
Python; what am I missing here?
Thanks -- Bill.