On Oct 18, 12:25 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > I prefer the calendar module in that case: > > py> import locale > py> locale.setlocale(locale.LC_ALL, '') > 'Spanish_Argentina.1252' > py> > py> import calendar > py> calendar.month_abbr[12] > 'Dic' > py> def prev_months(since, howmany): > ... return [calendar.month_abbr[(since.month-i-2) % 12 + 1] for i in > range(how > many)] > ... > py> import datetime > py> prev_months(datetime.datetime(2005,2,10), 4) > ['Ene', 'Dic', 'Nov', 'Oct'] > py> prev_months(datetime.datetime(2005,10,17), 3) > ['Sep', 'Ago', 'Jul']
Ah, you beat me to it. I was going to point out that if you're going to be using month strings, you should use calendar, since it can also use the correct locale. Plus, it offers a ridiculously simple solution to this problem compared to all the others. Hyuga -- http://mail.python.org/mailman/listinfo/python-list