Is there a Python function...

Stuart Ford stuart at forddata.com
Mon Aug 7 14:52:32 EDT 2000


And yes, I know there are much easier ways to get the month digit with
a list or dictionairy, but I wanted to be very basic in case any newbies 
were interested.


def GetMonth(str):
    months = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 
    'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] 
    return months.index(string.upper(str) )+1

or just load up a dictionary and pull the value.

That's what I love about python, so many ways to do the same
thing!!!


Stuart

    





More information about the Python-list mailing list