day1/exercise/datestring.py
author Christopher Burns <chris.d.burns@gmail.com>
Tue, 29 Jun 2010 00:30:21 -0500
branchscipy2010
changeset 431 9126059d6b37
parent 425 5afcfce15e71
permissions -rw-r--r--
DOC: Add slide about __module__ attribute.

month2mm = {'JAN': 1, 
            'FEB': 2, 
            'MAR': 3, 
            'APR': 4, 
            'MAY': 5, 
            'JUN': 6,
            'JUL': 7, 
            'AUG': 8, 
            'SEP': 9, 
            'OCT': 10, 
            'NOV': 11, 
            'DEC': 12 }

COMMA = ','
SPACE = ' '
date_str = raw_input('Enter a date string? ')
date_str = date_str.replace(COMMA, SPACE)
day, month, year = date_str.split()
dd = int(day)
mon = month[:3].upper()
mm = month2mm[mon]
yyyy = int(year)

print dd, mm, yyyy